From: David Alan Black Date: 2002-01-09T00:31:14+09:00 Subject: Re: chaining methods Hi -- On Wed, 9 Jan 2002, Tobias Reif wrote: > Hi, > > I'm looking for a nice way to chain methods in an API I'm writing. > > I'd like to be able to write > r.width=5.height=6 > , but then the receiver of height= is 5. > > So I have to write > (r.width=5).height=6 > ; the first expression returns a Rect. > > def height= value > add_attributes('height'=>value.to_s) > self > end > > What would be a simple way to make it possible to chain the above methods? I agree entirely with Paul, but one other thing.... In #height=, why add_attributes(...) instead of @height = value.to_s ? David -- David Alan Black home: dblack@candle.superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav