Shodhan Sheth
single n lookin

linkZ n feedZ

Site Feed(Atom)
Geeky Feed(RSS/Atom Combo)
BlogLines Subscription feed(RSS)

Powered by

Creative Commons License
This work is licensed under a Creative Commons License.

Friday, August 05, 2005

Komments on Ruby - 2

It's worth noting here a major difference between Ruby and most other languages. In (say) Java, you'd find the absolute value of some number by calling a separate function and passing in that number. You might write

number = Math.abs(number) // Java code

In Ruby, the ability to determine an absolute value is built into numbers---they take care of the details internally. You simply send the message abs to a number object and let it do the work.

number = number.abs
this is intresting. the point here is that one cannot exklusively define all operations possible on the class number. what if tomm theres a new formatting option out. i think that the java filosofy was to have methods for funktionalities on the number klass that number should not be aware of. this is a design issue. it is always safer to have objekts handle operations on self on their own. on the other hand, having a kommon klass for simple operations as deskribed above might lead to a smaller memory map.


Post a Comment

<< Home

Get awesome blog templates like this one from