package mantra.lang

Object

CLASS public class

The ultimate base class of all objects in Mantra. Defines default object equality, virtual method dispatch tables, and string representation.

🏗️ Constructor Summary

Constructor Signature
def __init__(self)

⚙️ Method Summary

Modifier & Return Type Method Signature Description
String to_string() Returns a human-readable string representation of the object instance.
Bool equals(other: Object) Evaluates reference and structural equality between this and other.
Int hash_code() Computes 64-bit integer identity hash code for associative containers.

🔍 Detailed Method Specifications

pub def to_string() -> String
Returns a human-readable string representation of the object instance.
pub def equals(other: Object) -> Bool
Evaluates reference and structural equality between this and other.
pub def hash_code() -> Int
Computes 64-bit integer identity hash code for associative containers.

💡 Example Usage

object_example.mantra
class CustomEntity extends Object:
    def __init__(self, name: String):
        self.name = name

    override pub def to_string() -> String:
        return "Entity(" + self.name + ")"