On Tuesday, July 01, 2014 12:58:30 PM Abinoam Jr. wrote:
> > But why this *greedy approach*, while I wouldn't be able to access it any
> > of the argument what may be passed or not ?
> 
> _You_ wouldn't be able to access it, but your 'super' friend will be.> 
> class Father
>   def initialize(*args)
>     puts "From Father, args were #{args.inspect}"
>   end
> end
> 
> class Son < Father
>   def initialize(*)
>     # I don't have any reference to the args.
>     # But my 'super' friend has
>     super
>   end
> end
> 
> Son.new
> Son.new "a", "b", "c", 1, :two, [3, 4], five: 5, six: 6, seven: 7
> 
> Great post Robert Klemme!
> 
> [From Robert post]
> "While we°«re at it: if you write a module which is intended as mixin
> and needs initialization itself the initializer should simply pass on> all arguments in order to be compatible with arbitrary inheritance
> chains:"
> 
> module AnotherMixin
>   # Prepare internal state and pass on all
>   # arguments to the super class
>   def initialize(*a, &b)
>     super
>     @list = []
>   end
> end
> 
> Abinoam Jr.

+1 to you and Robert both. Thanks for the detail answer. :-)


-- 
================
Regards,
Arup Rakshit
================
Debugging is twice as hard as writing the code in the first place. Therefore, 
if you write the code as cleverly as possible, you are, by definition, not 
smart enough to debug it.

--Brian Kernighan