From: Rich Kilmer Date: 2002-04-16T11:45:00+09:00 Subject: RE: RCR: xx: yy as shorter notation for :xx => yy Actually, since the current Ruby-way of faking out keyword arguments are: def method(x=nil, y=nil, z=nil) if x.kind_of? Hash x,y,z = x[:x], x[:y], x[:z] end puts x, y, z end 1) method(:x=>1, :z=>2) 2) method(1,2,3) If you allowed a hash to be defined by: "key: value" How would you distinguish between that dynamically building a hash (1 above) and your keyword argument idea in (3 below)? 3) method(x: 1, z: 2) I like the way that (1) dynamically builds a hash...it looks clean because you don't need the {} characters. I like your idea of "var: value" for keyword arguments. I think it makes very good syntactic sense. It 'feels' more like a symbol/var but the inversion of the : differentiates the intent. Being able to refactor this code as: def method(x=nil, y=nil, z=nil) puts x, y, z end 4) method(z: 2, x: 1) Is really nice. -rich > -----Original Message----- > From: Yukihiro Matsumoto [mailto:matz@ruby-lang.org] > Sent: Monday, April 15, 2002 10:10 PM > To: ruby-talk ML > Subject: Re: RCR: xx: yy as shorter notation for :xx => yy > > Hi, > > In message "RCR: xx: yy as shorter notation for :xx => yy" > on 02/04/16, Jean-Hugues ROBERT writes: > |I would like > | xxx: yyy > |to be equivalent to > | :xxx => yyy. > > Hmm, I was thinking to use "xxx: yyy" for keyword arguments in the > future release. But this one too is intresting. I'd like to hear > opinion from others. > > matz.