| Article: |
Ruby/Tk Primer: Creating a cron GUI Interface with Ruby/Tk | |
| Subject: | Answer to the self.puts dilema | |
| Date: | 2004-07-19 16:12:40 | |
| From: | Merc | |
|
Response to: Answer to the self.puts dilema
|
||
|
Just a style note. Unlike Python, Ruby doesn't require parentheses around method calls that take no arguments (in fact, under most circumstances, it doesn't require them around methods that take arguments). That's why you can say puts "Hello World!", rather than puts("Hello World!").
|
||
Showing messages 1 through 2 of 2.
-
Answer to the self.puts dilema
2004-07-19 20:30:53 Christopher Roach |
[Reply | View]




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.