print("Hello world!");
val anInt = 1;
val aString = "string";
val aBoolean = true;
val anArray = [1, 2, 3];
type SimpleObject {
property prop;
}
val anObject = new SimpleObject { prop: "this is a property" };
fun id(x) {
return x;
}
fun fact(n) {
if (n > 0) {
return n * fact(n-1);
}
return n;
}
val size = "hello".size();
type Person {
property firstName;
property lastName;
fun name() {
return firstName + " " + lastName;
}
}
val person = new Person {
firstName: "Kimmy",
lastName: "Leo"
};
val name = person.name();
val simpleArray = [1, 2, 3];
val arrayItem = simpleArray[0];
val twoDimArray = [[1, 2], [3, 4]];
val anotherItem = twoDimArray[1][0];
simpleArray[1] = 5;
simpleArray << 10;
file: external.ng
module external exports *;
fun hello() {
print("Hellp");
}
file: hello.ng
import "external" ext;
ext.hello();