On Wed, May 30, 2012 at 5:50 PM, Doug Jolley <lists / ruby-forum.com> wrote:
>> By the way: In Ruby you can leave out the parentheses for method calls
>> (unless there's ambiguity). So instead of
>>
>> puts(clubs.suit().inspect())
>>
>> you can simply write
>>
>> puts clubs.suit.inspect

> I've been meaning to respond to this. =A0Yes, I am aware of that fact.
> Some claim that it makes the code more readable. =A0I actually think that
> it does the opposite =A0and makes the code less readable. =A0The reason t=
hat
> I think that is that when I am reading Ruby code and I encounter an
> identifier by itself, I don't really know whether that identifier is a
> variable or a method. =A0If I see an identifier followed immediately by
> '()'; then, I know for sure that that identifier is a method.
> Consequently, I try to remember to use explicit parenthesis. =A0I doubt
> that I do a very good job; but, that's my thinking.

You need to do whatever feels best for you.  I'd just add if you do
not know whether something is a method or a local variable then your
methods might be too long or you use too many variables. :-)

Btw, in this particular case there is an even better way to rewrite the cod=
e:

p clubs.suit

or, if you prefer parens

p clubs.suit()
p(clubs.suit())

If you need to inspect more complex structures results are better when doin=
g

require 'pp'
pp clubs.suit
pp clubs.suit()
pp(clubs.suit())

Kind regards

robert

--=20
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/