Created
June 6, 2016 12:26
-
-
Save pvin/f7c8c41fd67116bc92ec011ddfee6558 to your computer and use it in GitHub Desktop.
ruby - difference between chop and chomp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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