How to convert an integer to a string in Erlang?

I know strings in Erlang can be costly to use. So how do I convert "5"to 5?

Is there anything like io:format("~p",[5]) that would return a formatted string instead of printing to a stream?


Solution 1:

There's also integer_to_list/1, which does exactly what you want, without the ugliness.

Solution 2:

A string is a list:

9> integer_to_list(123).  
"123"