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

Data Objects

Overview 

Sometimes, a fully-defined class is overkill, and all you need is a way to attach some methods to a piece of data (i.e. a Map).

Bound Methods 

When you assign an anonymous function to a Map key, any reference to @ inside the function will automatically be bound to the Map.

This lets you create dynamic objects on the fly, much like JavaScript’s object literals.

$user = {
    name: 'Tadala',
    job: 'Teacher',
    about: fn {
        return @.name ~ ' works as a ' ~ @.job
    },
}

$user.about()
//= 'Tadala works as a Teacher'