Created
April 13, 2010 13:55
-
-
Save norman/364636 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
# Ruby surprisingly clears the value of the $1 variable after a return | |
def test_gsub | |
result = "a".gsub(/(a)/, "b") | |
p $1 | |
result | |
end | |
test_gsub | |
p $1 | |
# Results: | |
# "a" | |
# nil |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment