Version: v0.7.1 - Beta.  We welcome contributors & feedback.

ObjectHooks.onToString

onToString() -> string

Description

This method is called whenever the object is converted to a string token, like when it is passed to the print function or serialized via JSON.encode.

It should return a standard string, which represents a summary of the object.

class User {

    ...

    public fn onToString {

        return @.userId
    }
}

$user = User()

print($user)
//= <User 1234>

See Also