From: Austin Ziegler Date: 2002-11-14T00:07:27+09:00 Subject: Re: Keyword arguments? On Wed, 13 Nov 2002 19:17:14 +0900, ahoward wrote: > On Tue, 12 Nov 2002, Vis Mike wrote: >> Keyword arguments help with ambiguity. > this is close > > class Person > def initialize args > @name = args[:name] > @age = args[:age] > end > end > > me = Person.new :name => 'ara', :age => 30 > > note that's a hash, not keywords - but you get the same effect. Dave & Andy also noted that you can make it so that initialize receives a block. Lyle recently implemented a change to the FXRuby code that makes the technique cleaner (in that you don't have to use 'self' all over the place), like so: class Person attr_accessor :name, :age def initialize(name = nil, age = nil) @name = name @age = age # ... default initialization yield self if block_given? end end me = Person.new { |who| who.name = 'austin' who.age = 31 } -austin -- Austin Ziegler, austin@halostatue.ca on 2002.11.13 at 09.59.51