Skip to content

Instantly share code, notes, and snippets.

@norman
Created April 13, 2010 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save norman/364636 to your computer and use it in GitHub Desktop.
Save norman/364636 to your computer and use it in GitHub Desktop.
# 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