Created
September 24, 2012 21:46
-
-
Save dplummer/3778624 to your computer and use it in GitHub Desktop.
Struct.new block and constancts
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
1.8.7 :001 > Foo = Struct.new(:id) do | |
1.8.7 :002 > BAR = 5 | |
1.8.7 :003?> end | |
=> Foo | |
1.8.7 :004 > BAR | |
=> 5 | |
1.8.7 :005 > Foo::BAR | |
(irb):5: warning: toplevel constant BAR referenced by Foo::BAR | |
=> 5 | |
1.9.3p194 :001 > Foo = Struct.new(:id) do | |
1.9.3p194 :002 > BAR = 5 | |
1.9.3p194 :003?> end | |
=> Foo | |
1.9.3p194 :004 > BAR | |
=> 5 | |
1.9.3p194 :005 > Foo::BAR | |
(irb):5: warning: toplevel constant BAR referenced by Foo::BAR | |
=> 5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment