0
Order of .chomp and .to_i
Does sit matter if the gets.chomp.to_i is written like that, or can you write it as gets.to_i.chomp
2 ответов
0
Since chomp is only defined for strings, gets.to_i.chomp should raise an error. Also, due to the way to_i ignores whitespace, chomp shouldn't be needed if you're doing gets.to_i
0
Dude i believe you have missed that its separate.
gets.chomp and gets.to_i are the methods NOT necessarily gets.chomp.to_i OR the other way around. to_i method i believe automatically removes the newline from the user input.