Ruby method chomp removes that newline character from the end of the text in the $_ variable. : chomp « Development « Ruby






Ruby method chomp removes that newline character from the end of the text in the $_ variable.


print "Please enter the temperature: "
gets
chomp
puts "The temperature is #{$_}."

 








Related examples in the same category

1.you don't need to use $_ with gets - you can assign the text it reads to any variable: temperature = gets