Overloads and Named Args
Overloads
Section titled “Overloads”Zap supports overloads with different parameter types:
fun mix(x: Int, y: Float) Int { return 1;}
fun mix(x: Float, y: Int) Int { return 2;}Named arguments
Section titled “Named arguments”Named arguments can improve readability and help overload resolution:
fun main() Int { if mix(y = 1.0, x = 2) != 1 { return 1; } if mix(y = 3, x = 4.0) != 2 { return 2; } return 0;}Example with labels
Section titled “Example with labels”fun build(width: Int, height: Int) Int { return width * height;}
fun main() Int { return build(height = 9, width = 16);}