buzz icon indicating copy to clipboard operation
buzz copied to clipboard

`Self` as reference to current object type

Open giann opened this issue 1 year ago • 0 comments

Not really useful in an object declaration since we can self reference there, but useful in protocols where we want to reference the actual object type.

protocol Clonable {
    fun clone() > Self;
}

object(Clonable) Person {
    str name,

    fun clone() > Self {
        return Person { name = this.name };
    }
}

giann avatar Jan 18 '24 07:01 giann