object:new()

Type Function
Object CoronaClass
Library none
Return value CoronaPrototype
Revision Release 2024.3703

Overview

Constructor for creating new object instances. The object is assumed to be a class object.

Syntax

object:new()
object:new( params )
params (optional)

Table. Optional table of parameters which can be passed to new() and forwarded to initialize() which can be overridden by subclasses.

Example

local Prototype = require( "CoronaPrototype" )

local paramsTable = { value = 3 }

local Foo = Prototype:newClass( "Foo" )
function Foo:initialize( params )
    print( params.value )
end

-- Pass params to initialize() which prints '3'
Foo:new( paramsTable )