Class: Toybox.Lang.Object

Inherits:
Toybox.Lang.Object show all

Overview

Object is the root object for the Monkey C class hierarchy.

Since:

API Level 1.0.0

Instance Method Summary collapse

Instance Method Details

equals(other as Lang.Object or Null) as Lang.Boolean

Test if an Object instance is equal to another instance of an Object.

Parameters:

  • other(Lang.Object)

    The Object to test against

Example:

var a = 1;
var b = 1;
var c = 1.0;
a.equals(b); // returns true
a.equals(c); // returns false

Returns:

  • Lang.Boolean

    true if Objects are equal, otherwise false

Since:

API Level 1.0.0

hashCode() as Lang.Number

Get a hash code value for an Object.

This computes a 32-bit Number that is typically used as an index when placing Objects into a Dictionary. Hash code values have the following characteristics:

  • The computed hash code is constant for the lifetime of an Object

  • If two Objects are equal, their hash codes will be equal

Returns:

See Also:

Since:

API Level 1.0.0

method(methodName as Lang.Symbol) as Lang.Method

Retrieve a callback to a Method.

This is typically used when supplying a callback function to another method.

Parameters:

  • methodName(Lang.Symbol)

    The Symbol of the specified Method

Returns:

  • Lang.Method

    A Method object for the specified Symbol

See Also:

Since:

API Level 1.0.0

toString() as Lang.String

Convert an Object to a String.

Example:

var myNumber = 3219;
var myString = myNumber.toString();

Returns:

  • Lang.String

    A String representation of the Object

Since:

API Level 1.0.0

weak() as Lang.WeakReference

Get a WeakReference to an Object.

A weak reference is an object that keeps a reference to an object but does not increment the reference count. This means the object reference can be destroyed, so is a case that should be handled.

Note:

Immutable types (Number, Float, Long, Double, Boolean, String) will return their values. Other Object types will return a WeakReference object.

Returns:

See Also:

Since:

API Level 1.2.0


Generated Dec 11, 2024, 8:58:43 AM