+ 2
Whats the difference between gets and gets.chomp
I really do not get the difference
1 Réponse
+ 8
gets retrieves one line of text, *including* the Enter press at the end.
For example, if you enter "Hello", and want to output it as:
puts "Your word is \"#{word}\"."
you would get:
Your word is "Hello
".
gets.chomp excludes the Enter press at the end.
The same example above would instead output:
Your word is "Hello".