From: Eric Mahurin Date: 2005-06-02T11:59:46+09:00 Subject: Re: ternary operator confusion --- Gavin Kistner wrote: > On Jun 1, 2005, at 4:42 PM, Charles Hixson wrote: > > Uniform access could have been achieved if only () was made > > > optional. (A good choice in my mind.) OTOH, I'm not that > happy > > with optional parenthesis where the parameters are > required. To me > > that feels like a bad design choice. (And with some type > faces the > > difference between (stuff) and {stuff} Yisn't all that > obvious. But > > that's a font problem...mainly.) > > Would you have prefered to be forced to write: > my_object.foo=( the_value ) > versus > my_object.foo = the_value > ? Now you are bring operators into the picture. Many (as above) do get translated to method calls, but operator syntax is completely independent of normal method call syntax. Although semantically the above is a method call, syntactically it is an assignment. If syntactically is was a method call, you would be able to do this: my_object.foo=(a,b) but you cannot because it treats (a,b) as the RHS which is invalid. Also, consider that you can do the following which get translated to 2 = methods. my_object.foo,your_object.bar = a,b Your argument is better suited for the ? methods that take an argument (i.e. respond_to?). I have to admit that I don't always put () around its argument because it it usually just a Symbol and not an expression. But, these ? method calls do seem to behave inconsistently: respond_to? :test # valid respond_to?:test # syntax error, why? respond_to?(:test) # valid self.respond_to? :test # valid self.respond_to?:test # valid self.respond_to?(:test) # valid __________________________________ Discover Yahoo! Find restaurants, movies, travel and more fun for the weekend. Check it out! http://discover.yahoo.com/weekend.html