J
Jeremy Henty
I've discovered that an unadorned call to "super" need *not* call the
parent method with the same arguments!!! If you bind the entire
argument list to a variable you can modify the list before calling
"super". Check it out:
class Show
def initialize(*args)
puts args.inspect
end
end
Show.new(1,34,"asd")
class Show2 < Show
def initialize(*args)
puts args.shift
super
end
end
Show2.new(1,34,"asd")
===>
[1, 34, "asd"]
1
[34, "asd"]
So "args" is bound to the *actual* array of arguments, not just a
copy. Is this a bug or a feature? Might this behaviour change in
future?
Regards,
Jeremy Henty
parent method with the same arguments!!! If you bind the entire
argument list to a variable you can modify the list before calling
"super". Check it out:
class Show
def initialize(*args)
puts args.inspect
end
end
Show.new(1,34,"asd")
class Show2 < Show
def initialize(*args)
puts args.shift
super
end
end
Show2.new(1,34,"asd")
===>
[1, 34, "asd"]
1
[34, "asd"]
So "args" is bound to the *actual* array of arguments, not just a
copy. Is this a bug or a feature? Might this behaviour change in
future?
Regards,
Jeremy Henty