Tim Hunter wrote: > [snip] > The method I started with is: > > def rect(x, y, width, height, rx=0, ry=0, styles=nil) > # blah, blah, blah > end > > Where the styles argument (if present) is a Hash formed by the usual > trailing key=>value pairs. All very standard Ruby. > > I was thinking that you'd create a square-corner rectangle like this: > > canvas.rect(10, 10, 20, 30, :fill=>'black', :stroke='red') > > But of course that doesn't work, because the styles hash > "{:fill=>'black', :stroke=>'red'}" gets assigned to rx, not to styles. > > Of course, within rect I could test the class of rx and/or ry and if it's a > Hash, assign it to styles, but that seems kludgy and insufficiently > Rubyish. I could divide rect into two methods, rect and rounded_rect, but > that means that the user has to remember an extra method name. I could make > rx and ry required arguments. Blech. > > Thoughts? def rect(x, y, width, height, *more) styles = more.pop || {} rx = more.shift || 0 ry = more.shift || 0 end This will however force you to specify the styles when you want to use a custom rx/ry. In general I guess it would be a good idea to just move rx/ry inside the styles hash. Regards, Florian Gross