So, why is the object constructor so long? I mean 'initialize' could easily
be replaced with 'init' or even just plain 'new'.
In support of this idea, I've noticed that to_string() is written to_s. The
same is with arrays, integers, and floats.
Even in the Pickaxe book it points out that the spelling of 'initialize' as
being a gotcha. 'Init' seems simpler, to the point, and harder to mispell.
Am I missing any major reasoning behind using the term 'initialize'?
(Besides the fact that is is the status quo)
-Clint
I suspect people call to_* more often than they call initialize.
But, poor speller that I am, one of the first gvim macros I wrote to
assist my Ruby hacking was a mapping that turned
defi
into
def initialize( )
end
So it became a non-issue for me.
(The other day I shoulder-surfed as someone coded Ruby using Notepad,
and it was so painful to watch even my hair hurt.)
--
James Britt
"Blanket statements are over-rated"
Ruby is specially designed to be friendly to use and read.
unix commands, by contrast, would be considered unfriendly,
but quicker to type. 'initialize' is within that friendly spirit.
Gerald
In message "Re: Ruby Syntax: 'initialize' versus 'init'"
on Sat, 4 Feb 2006 10:50:11 +0900, Clint Checketts <chec...@gmail.com> writes:
|Am I missing any major reasoning behind using the term 'initialize'?
|(Besides the fact that is is the status quo)
It can be very critical when the name of initializing method conflicts
with others, so that I chose "initialize" to avoid potential problems.
Besides that, the name was derived from T language (Scheme dialect).
matz.
Interesting you mention T, one question I always wanted to ask is:
Did the T object system influence the design of the Ruby object system?
(Or do you wish it did? ;))
> matz.
--
Christian Neukirchen <chneuk...@gmail.com> http://chneukirchen.org
On 2/4/06, Christian Neukirchen <chneuk...@gmail.com> wrote:
> Interesting you mention T, one question I always wanted to ask is:
> Did the T object system influence the design of the Ruby object system?
> (Or do you wish it did? ;))
No. I've heard it was pretty interesting but I didn't have any chance
to get the detail more than a small article, which mentioned an
intializer named "initialize".
matz.
It's very lightweight and almost trivial. In fact, I once ported it
to Ruby:
http://chneukirchen.org/blog/archive/2005/03/the-t-object-system-in-ruby.html