ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button
Article:
  Ruby/Tk Primer: Creating a cron GUI Interface with Ruby/Tk
Subject:   Answer to the self.puts dilema
Date:   2004-07-19 20:30:53
From:   christopher_roach
Response to: Answer to the self.puts dilema

You're absolutely correct — you do not need the parentheses in a Ruby method call. My use of the parentheses in the example was simply because I am so used to using them in C/C++ and Java in my daily work.


I did try to mention that Ruby does not need the parentheses (towards the middle of the third section), but I didn't really discuss any of the advantages of this property of the language. Therefore, I am glad that you pointed out that one of the advantages of not requiring the parentheses is Ruby's ability to treat a method like an attribute. Thus, setter and getter methods look just like direct attribute manipulation, giving the user the illusion that they are accessing data members directly while still following the OO concepts of data abstraction and encapsulation.


Thanks for the example.