Trans
10/13/2007 4:00:00 PM
On Oct 13, 7:55 am, arcadiorubiogar...@gmail.com wrote:
> Thank you both for your replies.
>
> Just a minor detail regarding:
>
>
>
> > require 'generator'
>
> > module InitializesWith
> > def initializes_with(*params)
> > define_method :initialize do |*args|
> > iterator = SyncEnumerator.new(params, args)
> > iterator.each do |param, arg|
> > instance_variable_set "@#{param}", arg
> > end
> > end
> > end
> > end
>
> > class Class
> > include InitializesWith
> > end
>
> This:
>
> > class C
> > attr_reader :x, :y, :z
> > initializes_with :x, :y, :z
> > end
>
> evaluates to a Proc object, due to initializes_with implementation. I
> guess it would be better to return nil at the end. Just a minor
> aesthetic detail as I said.
Return the attributes instead and you can do:
class C
attr_reader *initializes_with(:x, :y, :z)
end
T.