Quirrel4.41.0

types.Null.constructor

Method on every null
constructor(...): any

Returns null. This is what runs when types.Null itself is called, types.Null().

Return value

Always null, regardless of any arguments given.

Notes

null is the only value in this class, so unlike every other type's constructor there is nothing to convert: any arguments are read off the stack and thrown away, never inspected, so types.Null(1, 2, 3) is legal and still gives null. This never throws.

null has no other method - not tostring, tointeger, tofloat, clone or weakref. Calling any of those on null throws the index '<name>' does not exist, the plain missing-slot error, not a type-specific one. null still formats as "null" when print or string concatenation converts it implicitly, since that path does not go through a method lookup; see types.Bool.tostring for the same contrast on a type that does have the method.

constructor is a reserved word, but the parser special-cases it after a dot, so null.constructor() parses like an ordinary method call even though null has no other reachable methods.

Example

examples/types/null/constructor.nut
let types = require("types")
println("types.Null() =", types.Null())
println("types.Null(1, 2, 3) =", types.Null(1, 2, 3)) // extra arguments are accepted and ignored
println("type(types.Null()) =", type(types.Null()))

// unlike clone, "constructor" is not keyword-blocked after a dot
println("null.constructor() =", null.constructor())
Output:
types.Null() = null
types.Null(1, 2, 3) = null
type(types.Null()) = null
null.constructor() = null

See also

constructorConverts value to a bool. This is what runs when types.Bool itself is called, types.Bool(value).
constructorConverts value to an integer. This is what runs when types.Integer itself is called, types.Integer(value).
typeReturns the name of obj's type.
classofReturns the class that obj belongs to.
nullclass index