Kotlin infix 发表于 2019-08-16 | 分类于 Java , Kotlin ExampleAdd new add operation keyword12345678infix fun Int.add(x: Int): Int { return this + x}fun main() { val result = 100 add 200 println(result)} Add add operation to Class123456789101112131415class Account( private var balance: Double = 0.0) { infix fun add(amount: Double): Double { return this.balance.plus(amount) }}fun main() { val account = Account(10.0) val result = account add 1.0 println(result)}// result is 11.0