I clean up incoming command strings with cmd = line.strip!.downcase!. It works for most input, but for some lines I get NoMethodError: undefined method 'downcase!' for nil, and for others cmd ends up nil even though line looks fine. Replacing the bang methods with strip.downcase fixes it.
What does the exclamation mark mean on a Ruby method, why do these methods return nil, and when is it right to use them?




