From: gabriele renzi Date: 2005-06-08T04:05:26+09:00 Subject: Re: making a duck Eric Mahurin ha scritto: > --- Christian Neukirchen wrote: > >>gabriele renzi writes: >> >>>Eric Mahurin ha scritto: >>> >>> >>>>Is there another way to do this? With all of the talk >> >>about >> >>>>duck-typing, there would already be something out there to >> >>do >> >>>>this. >>> >>>There was some talk in the past about Object.new taking a >> >>block, which >> >>>imho would be useful for this. Meanwhile what about using >> >>Struct.new >> >>>with a block to define methods? >> >>Wow, this is nice... but where is it documented? nowhere, it seem. But I remebered it was discussed on ruby-core and tried it :) > So is Struct.new(&block) equivalent to: > > StructClass = Struct.new > StructClass.instance_eval(&block) > StructClass no, class_eval, and you have to submit at least one arg to Struct.new :/