Why we use gets. chomp method? Instead we can use gets only.. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 12

Why we use gets. chomp method? Instead we can use gets only..

24th May 2019, 10:08 PM
Hëllo Wörld🔰
Hëllo Wörld🔰 - avatar
2 Answers
+ 7
By default gets method will add a newline to your input. To remove it we use the chomp method g= gets #provide some input, lets say 'hi'. puts g+"hi" # hi # hi puts g.chomp + "hi" #hi hi
25th May 2019, 12:54 AM
Lord Krishna
Lord Krishna - avatar
+ 11
Thank you Lord Krishna
25th May 2019, 4:51 AM
Hëllo Wörld🔰
Hëllo Wörld🔰 - avatar