Edu’s quick notes

little asteroids here 
« Back to blog

Coolness, or ugliness?

In Ruby many operators are implemented as method calls. For example you can write:

>> 3 + 4
=> 7

as:

>> 3.+4
=> 7

In this case we call the method + on the Fixnum 3 and pass as argument the Fixnum 4.

>> 3.class
=> Fixnum

While it's good to have expressions built-in as methods, so the programmer can extend/modify them I think thay still relying on the receiver class to determine the method to be called is not the best solution. Personally I think that generic functions, found for example in Lisp, are a way better and more elegant solution

Comments (0)

Leave a comment...

 
Got an account with one of these? Login here, or just enter your comment below.
Posterous-login    Connect    twitter