Learning Ruby - Day 5

1 Apr 2005 in Programming, Ruby on Rails, Teach Yourself Ruby in 21 Days by Garrick

Day 5 is all about objects and their methods.

Remember a few months back when Apple introduced the Shuffle? Everyone was up-in-arms about it’s lack of screen and how it was useless an mp3 player without a screen is. When in-fact, the lack of screen simplifies and improves the device a great deal.

Ruby is like that; elegant, well thought out, useful, challenging convention. Case in point:

Methods names can end with ‘ =’. Conceptually treating a method’s values as variables. It not only saves keystrokes in comparison to the traditional methodName(value) convention - it more accurately maps to what’s being described.

Add to that, a built-in method for creating read & write methods - attr_accessor, an I’m understanding why Ruby is called the Programmers’ Best Friend.


This post documents my journey through Sam’s Teach Yourself Ruby in 21 days. I’ll be joining Al Abut in his effort to learn Ruby and blog along the way.


Comment | Trackback URL Short Link:

Comments (1 Comment)

The cool thing about having method names end with ‘=’ really is that you can do obj.field += 1, obj.field *= 10 etc. — that would be a lot less natural with Java- or Perl-style accessors.

flgr added these pithy words on Apr 04 05 at 5:12 pm

Add a Comment


XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Related Entries




Creative Commons License
About Sitemap XHTML Sitemap XML
Wordpress theme is a heavily hacked version of "Modicus Remix" by Art Culture. Original by Upstart Blogger