Methods keyword

func

Shorthand for void return type on methods.

Write func instead of declaring a void return type. Instance and static methods both support func. Other return types use Affogato-style name(params): Type or Java-style ReturnType name(...).

Affogato

example.aff
class Logger {
    func log(msg: String) {
        println(msg)
    }

    static func main(args: String[]) {
        println("Hello")
    }
}

Generated Java

Example.java
class Logger {
    public void log(String msg) {
        System.out.println(msg);
    }

    public static void main(String[] args) {
        System.out.println("Hello");
    }
}

Related

See also

← All keywords