method

chomp

v1_8_7_72 - Show latest stable - Class: String
chomp(...)
public

Returns a new String with the given record separator removed from the end of str (if present). If $/ has not been changed from the default Ruby record separator, then chomp also removes carriage return characters (that is it will remove \n, \r, and \r\n).

   "hello".chomp            #=> "hello"
   "hello\n".chomp          #=> "hello"
   "hello\r\n".chomp        #=> "hello"
   "hello\n\r".chomp        #=> "hello\n"
   "hello\r".chomp          #=> "hello"
   "hello \n there".chomp   #=> "hello \n there"
   "hello".chomp("llo")     #=> "he"

1Note

Argument Accepted

nhance ยท Jan 19, 20102 thanks

Accepts a single argument record_separator which is the character or string to chomp.

Why isn't this shown in the method def at the top?