Reputation: 13
Is there a way to put a variable in a io:get_line()
code? I tried
io:get_line("~s: ",[Variable]).
but it doesn't work. So my question is there another implementation for this?
Upvotes: 1
Views: 266
Reputation: 222398
You can pass the format string and arguments to io_lib:format/2
first, and then send that to io:get_line/1
:
1> Variable = "Name".
"Name"
2> io:get_line(io_lib:format("~s: ", [Variable])).
Name: Dogbert
"Dogbert\n"
Upvotes: 2