From: David Douthitt Date: 2000-06-13T10:20:05-05:00 Subject: [ruby-talk:03368] Re: chomp! >>> Dave@thomases.com 6/13/00 10:11a >>> "David Douthitt" writes: >> I was looking at the documentation for chomp and chomp! - and the >> results of chomp startled me to say the least. >Maybe, but it wouldn't be 'chomp'. Chomp removes the given >string (defaulting to a newline) from the end of another string >(in this case $_). It's typically used to remove newlines from >stuff you read in: >This is a a bone unashamedly thrown to the Perl converts. Like me :-) I would have described chomp and chomp! as removing a new line, if present, otherwise not affecting the string at all. This is what it does in Perl 5. In Perl 4, one used chop - which removed the last character (new line or not! :-) >> Also, the description for chomp! appears to be the same as for chomp >> - which it is not after CAREFUL examination. >chomp: > Equivalent to $_.chomp!(aString), except nil is never > returned. If $_ is changed, the new version is returned, > otherwise a copy of the original value is returned. See > String#chomp! on page 1. >chomp!: > Equivalent to $_.chomp!(aString). See String#chomp! >Am I missing something--I'm keen to make these reference >pages as accurate as possible. I was referring to the "See String#chomp!" on page 1. Unless you remember that you are ACTUALLY reading about Kernel#chomp and Kernel#chomp! it is easy to get confused and think that the description of Kernel#chomp! actually is String#chomp! - - see? Thanks for all your hard work! So when do we get to read it?