Skip to content

Instantly share code, notes, and snippets.

@broquaint
Created September 29, 2012 19:39
Show Gist options
  • Save broquaint/3805031 to your computer and use it in GitHub Desktop.
Save broquaint/3805031 to your computer and use it in GitHub Desktop.
Ruby's variable scope is not what I expect
$ cat > var-test.rb
s = 'yay?'
def f
puts s
end
f
$ ruby var-test.rb
var-test.rb:3:in `f': undefined local variable or method `s' for main:Object (NameError)
from var-test.rb:5:in `<main>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment