Kotlin miniguide #8 infix functions

Kotlin let the coder call a function or a method without using the dot notation:


class Person (age : Int) {

infix isOlderThan(p : Person) : Boolean {

return age > p.age

}

}

Person a = Person (34)

Person b = Person (34)

val ret = a isOlderThan b

The infix functions have only one parameter with no default value

Lascia un commento