From: Hal Fulton Date: 2005-06-02T11:46:48+09:00 Subject: Re: ternary operator confusion Eric Mahurin wrote: > > I wish Ruby didn't make the () optional when passing args > (probably from Perl which wanted to be like shells/tcl/lisp > where command/function and arguments are space separated). > > When you don't put the () in, the precendence can get confusing > and you arbitrarily prevent the first arg to start with a "(" > (otherwise it will treat that "(" as what starts the argument > list). > > Why do people feel the need to drop the ()? I didn't like it > in Perl and I don't like it in Ruby. Do people just want > something that is kind of like shell syntax? > Personally I like poetry mode in many cases (not all). When it's unclear, I use parens (just as I do in math expressions). Um, in case that didn't make sense: I sometimes use *unnecessary* parens in expressions for clarity. Does anyone *always* puts parens on method calls in Ruby? Maybe you or others do. Would you say attr_reader(:foo) for example? Or call the loop method this way? loop() { puts "I'm an infinite loop!" } What about raise and throw? Or exit? raise(AnException) throw(:something) exit() Be careful with super... these two can actually mean different things: super super() However, though I like poetry mode, I don't go as far as the person who uses it in method definitions: def mymeth a,b,c # this always makes me blink And I strongly tend to use parens in math functions: y = Math.sqrt(2) Just my opinion. Hal