I see people use the following code:
gets.chomp.to_i
or
gets.chomp.to_f
I don't understand why, when the result of those lines are always the same as when there is no chomp
after gets
.
Is gets.chomp.to_i
really necessary, or is gets.to_i
just enough?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…