Methods keyword

init

Explicit constructor keyword — replaces the Java class-name constructor.

Use init for custom constructor logic when compact class headers are not enough. The compiler lowers init blocks to standard Java constructors.

Affogato

example.aff
class User {
    let name: String!
    var count: int

    init(name: String!, count: int) {
        this.name = name
        this.count = count
    }
}

Generated Java

Example.java
class User {
    public final String name;
    public int count;

    public User(String name, int count) {
        this.name = name;
        this.count = count;
    }
}

Related

See also

← All keywords