Added dot chaining for functions

Well, it should work without issues...
This commit is contained in:
2022-10-14 23:58:15 +01:00
parent 168369d897
commit bd348abf32
4 changed files with 96 additions and 4 deletions

View File

@@ -1,5 +1,56 @@
import standard as std;
fn _b(self) {
print "running _b";
print self;
return self;
}
print std;
fn _c(self) {
print "running _c";
print self;
return self;
}
fn _d(self) {
print "running _d";
print self;
return self;
}
fn _e(self) {
print "running _e";
print self;
return self;
}
fn _f(self) {
print "running _f";
print self;
return self;
}
fn b() {
print "running b";
}
fn c() {
print "running c";
}
fn d() {
print "running d";
}
fn e() {
print "running e";
}
fn f() {
print "running f";
}
var a = 42;
print a.b().c().d().e().f();

View File

@@ -0,0 +1,22 @@
//test function chaining with the dot operator
fn _identity(self) {
return self;
}
fn _check(self) {
assert self == 42, "dot chaining failed";
return self;
}
var val = 42;
val
.identity()
.check()
.identity()
.check()
;
print "All good";