REMOVING NEWLINE CHARACTERS – CHOP AND CHOMP
A couple of handy string processing methods deserve special mention. The chop and chomp methods can be used to remove characters from the end of a string. The chop method returns a string with the last character removed or with the carriage return and newline characters removed (‚
‛) if these are found at the end of the string. The chomp method returns a string with the terminating carriage return or newline character removed (or both the carriage return and the newline character if both are found).