Created
August 18, 2014 13:47
-
-
Save AJFaraday/b2b4c3901542ef9bc579 to your computer and use it in GitHub Desktop.
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
# gsub! doesn't return anything when no changes are made | |
irb(main):006:0> 'abc'.gsub('c','d') | |
=> "abd" | |
irb(main):007:0> 'abc'.gsub!('c','d') | |
=> "abd" | |
irb(main):008:0> 'abc'.gsub!('d','c') | |
=> nil | |
# It's usual usage pattern (working on an existing object) still works | |
irb(main):002:0> a = 'abc' | |
=> "abc" | |
irb(main):003:0> a.gsub! 'd','' | |
=> nil | |
irb(main):004:0> a | |
=> "abc" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment