Skip to content

Instantly share code, notes, and snippets.

@dlt
Created December 2, 2011 01:56
Show Gist options
  • Save dlt/1421359 to your computer and use it in GitHub Desktop.
Save dlt/1421359 to your computer and use it in GitHub Desktop.
Why is 'y' defined?
ruby-1.9.2-p180 :001 > if 1 then x = 1 else y = 0 end
=> 1
ruby-1.9.2-p180 :002 > y
=> nil
ruby-1.9.2-p180 :003 > x
=> 1
ruby-1.9.2-p180 :004 > z
NameError: undefined local variable or method `z' for main:Object
from (irb):4
from /home/dlt/.rvm/rubies/ruby-1.9.2-p180/bin/irb:16:in `<main>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment