Hello Foo STDIN and strip
- STDIN
- gets
- strip
The solution is to remove the newline from the end of the string. We can do this using the strip
method:
print "Type in your name: "
person = STDIN.gets.strip
puts "Hello #{person}, how are you?"
Now if we run the program and identify as Bar
, the output will look the way we wanted:
Hello Bar, how are you?