Hi all,
just a quick check here. I did my due diligence on google.
Is there a pre built function in Elixir to convert boolean to string or is string interpolation the only way?
Am trying to do
bool = true
output = "That's" <> bool
Hi all,
just a quick check here. I did my due diligence on google.
Is there a pre built function in Elixir to convert boolean to string or is string interpolation the only way?
Am trying to do
bool = true
output = "That's" <> bool
to_string(bool)
https://hexdocs.pm/elixir/Kernel.html#to_string/1
https://hexdocs.pm/elixir/String.Chars.html
Oh my! Google search fail. Thanks for the enlightenment
You can also use string interpolation which automatically calls to_string
IE:
bool = true
"That's #{bool}"
He explicitely asked for an alternative to string interpolation.
Oops! That’s what I get for skimming the text and just looking at the code.
Heh, to be more specific string interpolation turns in to to_string/1
, so doing "blah '#{vwoop}'"
turns in to "blah '" <> to_string(vwoop) <> "'"
.