One liner in Ruby for displaying a prompt, getting input, and assigning to a variable?
Posted
by Jarsen
on Stack Overflow
See other posts from Stack Overflow
or by Jarsen
Published on 2010-05-22T20:53:48Z
Indexed on
2010/05/22
21:00 UTC
Read the original article
Hit count: 254
Often I find myself doing the following:
print "Input text: "
input = gets.strip
Is there a graceful way to do this in one line? Something like:
puts "Input text: #{input = gets.strip}"
The problem with this is that it waits for the input before displaying the prompt. Any ideas?
© Stack Overflow or respective owner