From: "T. Onoma" Date: 2003-11-18T19:14:50+09:00 Subject: Re: Again, Rite explanation needed (keyword args and new hash syntax) > Hi gurus and nubys, > > Again here to bother you :) whos the bigger bother? :) and i wouldn't think you could be rude. (well, maybe if you REALLY tried) > I wonder: > why we introduce the ':' syntax ? its an obvious refection of the new hash syntax. in essence he's saying: def f(a,:b=>2,**kwd) # == def f(a,b:2,**kwd) > Why can't we call a kwd arg like > f(1,b=5) > > I suppose this is to avoid conflicts with normal assignment.. > but what's wrong with making go away the assignment in method calling? i dobt that should go away, but to be honest, i am stumped on the sytax too. when i first saw it i thought "why more syntax" the parameters already have names. we only need a way to specify them in the method call, not in the def! that's were your = doesn't work. you can make an assignment in a method invocation. that's just common place. (perhaps not used a lot, but enough) but adding => or : sugar to calls causes a conflict with the way in which ruby currently handles hash parameters. so somethings got to give, in order to do: f(1,:b=>5) > PS > btw the 'a: c' syntax for hash is really cool. > > I always hate to type 'a'=>b or :a=>b. got a feeling symbols are going to get a lot more use if this happens. not sure how i feel about it. its certainly not bad, but it means even more syntax to understand. "hey nuby, a:4 and :a=>4 mean the same thing." > Nobody expects a string literal or a regexp literal to work like the > rest of the code. in what way? > But we expect this from Arrays and Hashes (and somewy Ranges). > This must mean something. yes, it cetainly does. > Possibly that I need more coffe in the morning. i'll drink to that. thanks for the bother, -t0