What is the difference between these three:
gets - it gets a line with '\n'
gets.chomp - it gets a line, but removes '\n'
Is that correct? What about gets.chomp! ?
gets - it gets a string with '\n' at the end ( or better to say the line separator $/ at the end) , then #chomp removes the \n ( or I would say the default value of $/),and give you a new string. But #chomp! did the same change in the receiver or the source string itself, on which you called #chomp! method.
Note : #chomp! is a bang version of #chomp.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With