Link Search Menu Expand Document

Object

Table of contents

  1. Object
    1. Object.getClassRef(String) -> Result<Object>
    2. Object.createFrom(String) -> Result<Object>
    3. Object.hash(Value) -> String
    4. Object.prettyPrint(Value, Number: indent -> Optional)

Object

To make use of the Object module an import is required.

import Object;

Object.getClassRef(String) -> Result<Object>

This method will attempt to get a class reference from the class name provided as a string.

Returns a Result and unwraps to an Object upon success.

NOTE: This currently only works if the class is defined in the global scope

class Test {}

Object.getClassRef("Test").unwrap(); // <Cls Test>

Object.createFrom(String) -> Result<Object>

This method will attempt to create a new object from the class name provided as a string.

Returns a Result and unwraps to an Object upon success.

NOTE: This currently only works if the class is defined in the global scope

class Test {}

Object.createFrom("Test").unwrap(); // <Test instance>

Object.hash(Value) -> String

This method will return a string of the object’s hash value.

NOTE Strings, Booleans, Nil will always return the same value since these values are interned.

Object.hash("Dictu");

Object.prettyPrint(Value, Number: indent -> Optional)

This method will output to stdout a string representation of the given value.

NOTE Strings, dicts, lists, numbers, booleans, and nil are valid values for pretty printing at this time.

Object.prettyPrint([1, 2, 3]);

// Output
'[1, 2, 3]'
Object.prettyPrint({"a": 1}, 4);

// Output
'
{
    "a": 1
}
'

This site uses Just The Docs, with modifications.