I'm a ruby beginner. I have the following code which asks the user for his name and prints it back.
print 'Enter your name : '
name = gets()
print("Hey,#{name} !")
If I enter John Doe as the name, the output is as follows
Hey,John Doe
!
print
unlike puts
does not automatically put a new line after output but I've noticed that in the above case anything I enter after #{name}
is printed on a new line. Why is this so ?
name
contains a character you typed in (pressed a key for) but are not expecting. – Adenoidectomy