Skip to content

Instantly share code, notes, and snippets.

@pvin
Created June 6, 2016 12:26
Show Gist options
  • Save pvin/f7c8c41fd67116bc92ec011ddfee6558 to your computer and use it in GitHub Desktop.
Save pvin/f7c8c41fd67116bc92ec011ddfee6558 to your computer and use it in GitHub Desktop.
ruby - difference between chop and chomp
#Be careful not to confuse chomp with the chop method. The chop method will simply knock off the last character of the
#string, no matter what it is
"hello\n".chomp
#=> "hello"
"hello".chomp
#=> "hello"
"hello".chop
#=> "hell"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment