allocateallocates memory for the instance Foobut does not initialize .
initializecalled on an already selected object to initialize (set the initial values) the instance Foo.
The newdefault implementation performs the following functions by default:
class Foo
def self.new(*args, &blk)
obj = allocate
obj.initialize(*args, &blk)
obj
end
end
. new (, C, MRI), Ruby. - Ruby, , .
, , , Foo.
initialize , , , Foo.new , Foo.allocate, , Foo.new, .
( new , , ).