James Gray
10/3/2004 3:48:00 AM
I'm happily devouring the new Pickaxe and early on I run across an
example like:
... Integer( string_holding_number ) ...
This syntax REALLY surprised me.
1. The book has mentioned multiple times how C's abs(num) or Java's
Math.abs(num) would be num.abs in Ruby.
2. Method names in Ruby start with a lowercase letter. (As an aside,
this made it hard for me to even find this method. I tried ri first and
got the class. Luckily, the book's excellent index got me there.)
3. The above ends up feeling like a constructor, now that I've read
the process, but doesn't use constructor syntax either.
I'll confess to not being very "Duck Typing" aware, so I assume I'll
understand the need for this method after I cover the chapter on that
topic. In the meantime though, can I just ask where this syntax came
from??? I get that it's the resulting object name (I found Array(),
Float() and String() too), but it still seemed pretty radical to me.
I'm not complaining, by the way. I'm just trying to understand.
Thanks.
James Edward Gray II