Version: v0.8.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.

The string token will appear as ⟪ ClassName $summary ⟫

class User {

    ...

    public fun onToString {

        return @.userId
    }
}

$user = User()

print($user)
//=《 User 1234 》

See Also