Created
January 27, 2012 10:29
-
-
Save dcarley/1688192 to your computer and use it in GitHub Desktop.
Ruby magically assigns nil to untouched variable.
This file contains hidden or 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
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