Skip to content

Instantly share code, notes, and snippets.

@bendmorris
Created October 26, 2018 23:18
Show Gist options
  • Save bendmorris/17b27f614201c186a71a2b4c692fd29b to your computer and use it in GitHub Desktop.
Save bendmorris/17b27f614201c186a71a2b4c692fd29b to your computer and use it in GitHub Desktop.
Kit: trait method forwarding
trait MyTrait {
public function doSomething(): Void;
}
abstract MyType: Int {
rules {
($this.doSomething) => $this.MyTrait.doSomething;
}
}
implement MyTrait for MyType {
public function doSomething() {
printf("hi!\n");
}
}
function main() {
var x: MyType = 1;
x.doSomething();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment