String.rstrip!

Signature

string.rstrip!    #=> string or nil

String.rstrip! is the in-place edit version of
String.rstrip.
string.rstrip! returns string with trailing whitespace removed from
string or it returns nil if no trailing whitespace was found.

Examples

str = "foo bar \r\n\t"    #=> "foo bar \r\n\t"
str.rstrip!               #=> "foo bar"
str == "foo bar \r\n\t"   #=> false
str == "foo bar"          #=> true
str.rstrip!               #=> nil

Documentation Reference

www.ruby-doc.org : String.rstrip!