Skip to main content

Objects and Classes

Zymba supports object-oriented programming through new object() definitions. Objects combine data (properties) and behavior (methods) into reusable units.

Zymba does not have classical inheritance with extends. Instead, it encourages composition — building complex objects from simpler ones through delegation, factory functions, and the mixin pattern.

Object introspection

Check object structure at runtime with the in operator and @Array.listKeys:

ZYMBA
$obj = new object() {
name = "test";
getValue() { return $this.name; }
};

// Check if property/method exists
if ("name" in $obj) {
echo "Has name property";
}

// Get all keys (properties and methods)
$keys = @Array.listKeys($obj);

See also

  • Objects — anonymous objects, methods, $this, cloning, reference semantics
  • Classes — class templates, constructors, instances, method chaining, dynamic methods
  • Composition — composition patterns, factory functions, ZeyOS platform objects