Skip to content

Instantly share code, notes, and snippets.

@swistak35
Created February 21, 2015 00:09
Show Gist options
  • Save swistak35/e79976173b309fa0cf67 to your computer and use it in GitHub Desktop.
Save swistak35/e79976173b309fa0cf67 to your computer and use it in GitHub Desktop.
$... are global variables, except that no
str = "The quick fox and dog trololo"
/fox/.match(str)
def search2(str)
/and/.match(str)
puts "Inside method2: #{$&}"
end
def search(str)
/dog/.match(str)
search2(str)
puts "Inside method: #{$&}"
end
search(str)
puts "Outside method: #{$&}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment