I learned that gets
creates a new line and asks the user to input something, and gets.chomp
does the same thing except that it does not create a new line. gets
must return an object, so you can call a method on it, right? If so, lets name that object returned by gets
as tmp
, then you can call the chomp
method of tmp
. But before gets
returns tmp
, it should print a new line on the screen. So what does chomp
do? Does it remove the new line after the gets
created it?
Another way to re-expound my question is: Are the following actions performed when I call gets.chomp
?
gets
prints a new linegets
returnstmp
tmp.chomp
removes the new line- User input
Is this the right order?
See Question&Answers more detail:os