M
Michael Lesniak
Hello,
I'm reading whys poignant guide to ruby at the momemt and am in the
chapter of metaprogramming. There is one thing in the Creature-Example
I don't understand.
A short example to exemplify
--- snip ---
class Foo
def self.method(val)
@var = val
p instance_variables
end
end
class Bar < Foo
method true
end
--- snap ---
Execution returns "[@var]". But since @var is an instance-variable,
where is is stored. Shouldn't it be set first when an instance is
allocated?
Thanks for help,
Michael
I'm reading whys poignant guide to ruby at the momemt and am in the
chapter of metaprogramming. There is one thing in the Creature-Example
I don't understand.
A short example to exemplify
--- snip ---
class Foo
def self.method(val)
@var = val
p instance_variables
end
end
class Bar < Foo
method true
end
--- snap ---
Execution returns "[@var]". But since @var is an instance-variable,
where is is stored. Shouldn't it be set first when an instance is
allocated?
Thanks for help,
Michael