ruby strip vs strip!

Thursday 11/27/2008  –  Category: Uncategorized

Sorry to disappoint, but this entry isn't about strippers.

str.strip returns a copy of string str with with whitespace chopped off, while str.strip! returns the same string str or nil if the string wasn't altered.

I didn't realize str.strip! would return nil until I was getting a lot of empty strings back...

Leave a Reply