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