# \[FAQ\] When should a method have parentheses?

**URL:** <https://rubytalk.org/t/faq-when-should-a-method-have-parentheses/4260>\
**Category:** ruby-talk\
**Created:** [22 January 2003 04:46 UTC](https://rubytalk.org/t/faq-when-should-a-method-have-parentheses/4260 "2003-01-22T04:46:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gavin\_Sinclair](https://avatars.discourse-cdn.com/v4/letter/g/db5fbb/32.png) [@Gavin\_Sinclair](https://rubytalk.org/u/Gavin_Sinclair)\
**Post date:** [22 January 2003 04:46 UTC](https://rubytalk.org/t/faq-when-should-a-method-have-parentheses/4260/1 "2003-01-22T04:46:31Z")

</div>

Hi -talk,

An unanswered question appears on the FAQ page. Actually, a few do,  
but this is oldest so I’ll tackle it first. The problem is: I have no  
idea. Can someone provide an answer, and I’ll update the FAQ.

Question: When should a method have parentheses?

Comment: Sometimes Ruby 1.7.x warns that parentheses will be required  
in the future.

Happy answering!

Gavin

---

<div class="post-metadata">

**Author:** ![Dmitri\_Colebatch](https://avatars.discourse-cdn.com/v4/letter/d/f1d935/32.png) [@Dmitri\_Colebatch](https://rubytalk.org/u/Dmitri_Colebatch)\
**Post date:** [22 January 2003 04:48 UTC](https://rubytalk.org/t/faq-when-should-a-method-have-parentheses/4260/2 "2003-01-22T04:48:40Z")

</div>

From [http://www.rubycentral.com/book/tut\_methods.html](http://www.rubycentral.com/book/tut_methods.html)

The optional parameters follow the method name. If there is no ambiguity  
you can omit the parentheses around the argument list when calling a  
method.[Other Ruby documentation sometimes calls these method calls  
without parentheses ``commands.‘’] However, except in the simplest cases  
we don’t recommend this—there are some subtle problems that can trip  
you up.[In particular, you must use parentheses on a method call that is  
itself a parameter to another method call (unless it is the last  
parameter).] Our rule is simple: if there’s any doubt, use parentheses.

maybe a pointer there would be appropriate?

Gavin Sinclair wrote:

> **···**
>
> > Hi -talk,
> > 
> > An unanswered question appears on the FAQ page. Actually, a few do,  
> > but this is oldest so I’ll tackle it first. The problem is: I have no  
> > idea. Can someone provide an answer, and I’ll update the FAQ.
> > 
> > Question: When should a method have parentheses?
> > 
> > Comment: Sometimes Ruby 1.7.x warns that parentheses will be required  
> > in the future.
> > 
> > Happy answering!
> > 
> > Gavin

---

<div class="post-metadata">

**Author:** ![Gavin\_Sinclair](https://avatars.discourse-cdn.com/v4/letter/g/db5fbb/32.png) [@Gavin\_Sinclair](https://rubytalk.org/u/Gavin_Sinclair)\
**Post date:** [22 January 2003 05:07 UTC](https://rubytalk.org/t/faq-when-should-a-method-have-parentheses/4260/3 "2003-01-22T05:07:13Z")

</div>

Thanks for the quick response, Dmitri. Unfortunately there is an  
unwritten context to the question that you would not have gained,  
having joined the list only recently.

I agree that parentheses should be used whenever there is any doubt,  
and I in fact use them most of the time. However, there was a case a  
while ago where ‘p (0…5)’ failed or something, and the answer was  
that parentheses were required in a place where you might not expect.  
I think that’s where the question came from.

Ultimately, though, I’m not sure there will be a suitable answer for  
the FAQ.

Finally, please note that in this list, it is preferable to write your  
reply in the context of the message, not at the top.

Cheers,  
Gavin

> **···**
>
> On Wednesday, January 22, 2003, 3:48:40 PM, Dmitri wrote:
> 
> > From [http://www.rubycentral.com/book/tut\_methods.html](http://www.rubycentral.com/book/tut_methods.html)
> 
> > The optional parameters follow the method name. If there is no ambiguity  
> > you can omit the parentheses around the argument list when calling a  
> > method.[Other Ruby documentation sometimes calls these method calls  
> > without parentheses ``commands.‘’] However, except in the simplest cases  
> > we don’t recommend this—there are some subtle problems that can trip  
> > you up.[In particular, you must use parentheses on a method call that is  
> > itself a parameter to another method call (unless it is the last  
> > parameter).] Our rule is simple: if there’s any doubt, use parentheses.
> 
> > maybe a pointer there would be appropriate?
> 
> > Gavin Sinclair wrote:
> > 
> > > Hi -talk,
> > > 
> > > An unanswered question appears on the FAQ page. Actually, a few do,  
> > > but this is oldest so I’ll tackle it first. The problem is: I have no  
> > > idea. Can someone provide an answer, and I’ll update the FAQ.
> > > 
> > > Question: When should a method have parentheses?
> > > 
> > > Comment: Sometimes Ruby 1.7.x warns that parentheses will be required  
> > > in the future.
> > > 
> > > Happy answering!
> > > 
> > > Gavin

---

<div class="post-metadata">

**Author:** ![Dmitri\_Colebatch](https://avatars.discourse-cdn.com/v4/letter/d/f1d935/32.png) [@Dmitri\_Colebatch](https://rubytalk.org/u/Dmitri_Colebatch)\
**Post date:** [22 January 2003 05:14 UTC](https://rubytalk.org/t/faq-when-should-a-method-have-parentheses/4260/4 "2003-01-22T05:14:41Z")

</div>

Gavin Sinclair wrote:

> Thanks for the quick response, Dmitri. Unfortunately there is an  
> unwritten context to the question that you would not have gained,  
> having joined the list only recently.

ahhh, one of them… ok, I’ll sit back then (o:

[snip]

> Finally, please note that in this list, it is preferable to write your  
> reply in the context of the message, not at the top.

😃 I cant resist… yeah, I was lazy… but erm… “do as I say not  
as I do”? hehe…

cheers  
dim
