[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Constructors

exiquio

11/3/2008 4:02:00 PM

The following is the beginning of a Java-esque new operator.

def new o
o.class == Class ? o.new : o
end

Used with the String class you can do:

new String # => ""
new String('foo') # => "foo"

But this is not the case with a class like Object:

new Object # okay
new Object() # error

My question is, what are classes like Array and String defining that
Object isn't? And how can I define my own? Thanks in advanced.