Skip to content

Instantly share code, notes, and snippets.

@dcarley
Created January 27, 2012 10:29
Show Gist options
  • Save dcarley/1688192 to your computer and use it in GitHub Desktop.
Save dcarley/1688192 to your computer and use it in GitHub Desktop.
Ruby magically assigns nil to untouched variable.
irb(main):001:0> foo
NameError: undefined local variable or method `foo' for main:Object
from (irb):1
from :0
irb(main):002:0> if false
irb(main):003:1> foo = "bar"
irb(main):004:1> end
=> nil
irb(main):005:0> foo
=> nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment