Skip to content
instance method

Class#allocate

() -> untyped
class.allocate() → obj

Allocates space for a new object of class’s class and does not call initialize on the new instance. The returned object must be an instance of class.

Example
klass = Class.new do
  def initialize(*args)
    @initialized = true
  end

  def initialized?
    @initialized || false
  end
end

klass.allocate.initialized? #=> false
See also .new #attached_object #inherited also in 4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0