map can have function members by placing function declaration between the curly braces

This commit is contained in:
Francesco Cozzuto
2023-01-13 03:02:28 +01:00
parent 189bfa030b
commit 920b88c006
8 changed files with 208 additions and 131 deletions
+15
View File
@@ -0,0 +1,15 @@
Person = {name: String, age: int, sayHello: Callable};
fun newPerson(name: String, age: int)
return {
name: name,
age: age,
fun sayHello(self)
print("Hello from ", self.name, "!\n");
};
me = newPerson("Francesco", 24);
me->sayHello();
assert(istypeof(Person, me));