Gregory Brown wrote: > On Sat, Jun 27, 2009 at 4:52 PM, Fabian > Streitel<karottenreibe / googlemail.com> wrote: ... >>> def name(*args) >>> return @name if args.empty? >>> @name = args.first >>> end >> Better, but IMHO that's WAY too much overhead for something as basic as a >> setter. >> After all, you have to construct an array everytime you access the setter... > > Huh? This is the way Ruby arguments work no matter what. Using *args > just gives you raw access to the arguments. No, *args does construct an array. >> def f1(a,b,c);end => nil >> def f2(*args);end => nil >> GC.start; 1000.times {f1(1,2,3)}; ObjectSpace.each_object(Array) {} => 2119 >> GC.start; 1000.times {f2(1,2,3)}; ObjectSpace.each_object(Array) {} => 3119 >> GC.start; 1000.times {f1(1,2,3)}; ObjectSpace.each_object(Array) {} => 2119 >> GC.start; 1000.times {f2(1,2,3)}; ObjectSpace.each_object(Array) {} => 3119 -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407