this is really just a question of taste i think, but i’m wondering if you
think super’s position should be kept irrelevant? in the example below the
puts @avar will return nil. super has to be placed below @avar = 1 for it to
return 1.
class Sup
def initialize
puts @avar
end
end
class Chi < Sup
def initialize
super # will puts nil
@avar = 1
# super # would puts 1
end
end
the other option to make it irrelevent is:
class Sup
def initialize
end
def go
puts @avar
end
end
class Chi < Sup
def initialize
super
@avar = 1
go
end
end
of course, now go’s position is important, but not super’s. which is
preferrable?
-transami
to me, that’s the least suprising way to work. when you call super
before setting the instance variable, the puts of the variable springs
it into existence with nil as a value (Perl calls it autovivification i
think). the output comes before the setting of the variable, and nothing
happens after setting it.
in the second setup, super.initialize doesn’t DO anything, but #go does,
and the instance variable is set BEFORE #go is run. super’s position in
the second example isn’t important because super.initialize is not doing
anything 
-Justin
···
On Sunday, January 5, 2003, at 06:07 , Tom Sawyer wrote:
this is really just a question of taste i think, but i’m wondering if
you
think super’s position should be kept irrelevant? in the example below
the
puts @avar will return nil. super has to be placed below @avar = 1 for
it to
return 1.
class Sup
def initialize
puts @avar
end
end
class Chi < Sup
def initialize
super # will puts nil
@avar = 1
# super # would puts 1
end
end
the other option to make it irrelevent is:
class Sup
def initialize
end
def go
puts @avar
end
end
class Chi < Sup
def initialize
super
@avar = 1
go
end
end
of course, now go’s position is important, but not super’s. which is
preferrable?
It’s not a question of relevance - it’s just that super returns a value,
and if it’s the last statement in your method, that value will be the
method’s return value. I don’t see any real way around that.
martin
···
Tom Sawyer transami@transami.net wrote:
this is really just a question of taste i think, but i’m wondering if you
think super’s position should be kept irrelevant? in the example below the
puts @avar will return nil. super has to be placed below @avar = 1 for it to
return 1.
Misread your post - please ignore 
martin
···
Martin DeMello martindemello@yahoo.com wrote: