chop! ruby

The chop! method in Ruby removes the last character of the string and returns the removed character or nil. It modifies the original string. If the string is empty, it returns an empty string. If the string ends with a carriage return, it removes it. If the string ends with a carriage return followed by a newline, it removes the newline. If the string ends with a newline, it removes it. If the string ends with any other character, it removes that character.