Skip to content

Instantly share code, notes, and snippets.

@krazylegz
Forked from powellnathanj/gist:2631229
Created May 7, 2012 23:06
Show Gist options
  • Save krazylegz/2631270 to your computer and use it in GitHub Desktop.
Save krazylegz/2631270 to your computer and use it in GitHub Desktop.
[root@cramp ~]# irb
irb(main):001:0> @foo = Struct.new(:foo, :bar)
=> #<Class:0x2b40c83d5bb0>
irb(main):002:0> def create_structure(arr)
irb(main):003:1> f = @foo.new(arr[0], arr[1])
irb(main):004:1> puts f.foo
irb(main):005:1> end
=> nil
irb(main):006:0> create_structure(["foo", "bar"])
NameError: undefined local variable or method `foo' for main:Object
from (irb):3:in `create_structure'
from (irb):6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment