Methods syntax

Optional new

Constructor calls work with or without the new keyword.

Type(args) and new Type(args) are equivalent for constructor calls. Named arguments pair naturally with the new-less form.

Affogato

example.aff
let a = Dog("Fido")
let b = new Dog("Rex")
let list = List<String>()

Generated Java

Example.java
final Dog a = new Dog("Fido");
final Dog b = new Dog("Rex");
java.util.List<String> list =
    new java.util.ArrayList<String>();

Related

See also

← All keywords