Files
wren/doc/site/modules/core/object.markdown
T
Bob Nystrom 909c242a03 chore: reorganize doc site structure by moving core docs under modules/ and removing category metadata
Restructure the documentation hierarchy to prepare for documenting additional built-in modules. Move all core library documentation from `doc/site/core/` to `doc/site/modules/core/`, rename `modules.markdown` to `modularity.markdown`, remove `^category` metadata lines from all affected pages, update cross-reference links to use relative paths under the new structure, and add a TODO placeholder to the Class class page.
2015-11-08 21:31:22 +00:00

1.5 KiB

^title Object Class

Static Methods

same(obj1, obj2)

Returns true if obj1 and obj2 are the same. For value types, this returns true if the objects have equivalent state. In other words, numbers, strings, booleans, and ranges compare by value.

For all other objects, this returns true only if obj1 and obj2 refer to the exact same object in memory.

This is similar to the built in == operator in Object except that this cannot be overriden. It allows you to reliably access the built-in equality semantics even on user-defined classes.

Methods

! operator

Returns false, since most objects are considered true.

==(other) and !=(other) operators

Compares two objects using built-in equality. This compares value types by value, and all other objects are compared by identity—two objects are equal only if they are the exact same object.

is(class) operator

Returns true if this object's class or one of its superclasses is class.

:::wren
System.print(123 is Num)     //> true
System.print("s" is Num)     //> false
System.print(null is String) //> false
System.print([] is List)     //> true
System.print([] is Sequence) //> true

It is a runtime error if class is not a Class.

toString

A default string representation of the object.

type

The Class of the object.