Metaprogramming and instance variables
- From: "Michael Lesniak" <michael.lesniak@xxxxxxxxx>
- Date: 15 Jun 2006 01:34:36 -0700
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
.
- Follow-Ups:
- Re: Metaprogramming and instance variables
- From: Marcin Mielżyński
- Re: Metaprogramming and instance variables
- From: Daniel Schierbeck
- Re: Metaprogramming and instance variables
- Prev by Date: Rake db:migrate
- Next by Date: Re: Metaprogramming and instance variables
- Previous by thread: Rake db:migrate
- Next by thread: Re: Metaprogramming and instance variables
- Index(es):