From: Trans Date: 2007-11-04T07:43:44+09:00 Subject: Re: Passing keyword arguments On Nov 3, 4:47 am, "Robert Dober" wrote: > On Nov 3, 2007 1:27 AM, Trans wrote: > > > Lets say I have a method using the not-so-uncommon keyword options > > pattern: > > > def foo(*args) > > opts = (Hash === args.last ? args.pop : {}) > > Hi Tom > > irb(main):001:0> def foo *args > irb(main):002:1> opts, args = args.partition{|x| Hash === x } > irb(main):003:1> opts = opts.inject{ |s,x| s.update x } > > seems this should do the trick > > > ... > > > Now I want to define another method, which is essentially a special > > alias, that places a particular option as the first argument: > > > def bar(opt, *args) > > foo(*args, :baz => opt) # doesn't work. > > now it does , almost > foo( :baz => opt, *args) Interesting approach. Thanks. T.