chomp! returns nil without altering the string because there is no record separator at the end of the string : chomp « String « Ruby






chomp! returns nil without altering the string because there is no record separator at the end of the string


joe = <<limerick
T
q
limerick

joe.chomp!
puts joe
joe.chomp!
puts joe
joe.chomp! # => nil
puts joe

 








Related examples in the same category

1.The chomp and chop Methods
2.chomp and chomp!