Is it ever necessary to use 'chomp' before using `to_i` or `to_f`?

Viewed 2790

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?

3 Answers
Related