Gary Wright wrote: > > On Mar 2, 2007, at 12:39 AM, Joel VanderWerf wrote: >> There seems to be still some ambiguity in this description. In this case: >> >> h = {3 => 4} >> A.new(1, 2, h) >> >> how do you know if _h_ is intended as the third object (in the "zero >> or more objects" part) or as the optional hash? > > You don't. There just has to be a clear documentation for > the disambiguation rule. The caller could use: > > A.new(1,2, h, {}) > > If they wanted to force h to be part of the list of objects > instead of the optional trailing hash. Another possibility, unless you need to use the block that's passed to A.new for something else: class A def initialize(*args) @args = args @opts = block_given? ? yield : {} puts "args=#{@args.inspect} opts=#{@opts.inspect}" end end A.new(1, 2, 3) # args=[1, 2, 3] opts={} A.new(1, 2, 3) {{4=>5, 6=>7}} # args=[1, 2, 3] opts={6=>7, 4=>5} A.new(1, 2, {3=>4}) # args=[1, 2, {3=>4}] opts={} A.new(1, 2, 3=>4) # args=[1, 2, {3=>4}] opts={} But that's syntactically less tidy. -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407