On Sep 20, 2006, at 2:15 AM, Henrik Schmidt wrote: > Hi there, > > I'm fairly new to Ruby, so bear with me. Anyway, on with the question. > > What is the benefit of being able to omit parentheses on a method > call? '(' and ')' is harder to type than just ' ' > IMHO, parentheses improves readability; I can instantly discern, > whether something is a method call or a variable. I don't like code that looks like this, it is highly unreadable: foo(bar(arg1), baz(2, arg2)) This is not an improvement: foo bar(arg1), baz(2, arg2) This is an improvement: blah1 = bar arg1 blah2 = baz 2, arg2 foo blah1, blah2 > It would seem to me, that readability is, at least, part of the > reason for the @-prefix on instance variables, thus making it > difficult for a human reader to confuse them with local variables. > Why not force a similar convention on method calls, namely explicit > parentheses? > > In addition, this feature allows you to do stuff like this: > > def foo > 42 > end > > foo # -> 42 > foo = 1 if false > foo # -> nil > > I generally like the language but dead code with side effects makes > me nervous. This really is a non-issue. You trip over it once and don't do it again. > Could anyone explain to me, why it's a good idea to have the option > of omitting parentheses on a method call? It encourages writing readable code by making already unreadable code even more ugly. There's a lot of things that are possible to do with ruby, but are either hard, ugly, or both. They're that way for a reason (because you're probably doing something wrong if you are doing those things). -- Eric Hodel - drbrain / segment7.net - http://blog.segment7.net This implementation is HODEL-HASH-9600 compliant http://trackmap.robotcoop.com