Anonymous objects
Anonymous objects are objects that you create on the fly using brackets. The following is an example:
{ age : 12, name : "Benjamin" };
This object, despite not being created from any class, is typed. Its type is: {age
:Int,
name
:
String}
.
The following is an example that you can run:
class TesthaXe { public static function main(): Void { var user = {name : "Benjamin", age:12}; neko.Lib.println("User " + user.name + " is " + user.age + " years old."); } }
This program will print User
Benjamin
is
12
years
old
.