Complete the code to define a function that adds two numbers using operator overloading.
operator fun Int.[1](other: Int): Int = this + otherIn Kotlin, the plus function is the operator function for the + operator.
Complete the code to overload the '*' operator for a custom class.
class Multiplier(val value: Int) { operator fun [1](other: Multiplier): Multiplier { return Multiplier(this.value * other.value) } }
The times function corresponds to the '*' operator in Kotlin.
Fix the error in the operator function name to correctly overload the '-' operator.
operator fun Int.[1](other: Int): Int = this - otherThe correct operator function name for '-' is minus.
Fill both blanks to create a custom operator function for the '%' operator.
class Mod(val number: Int) { operator fun [1](other: Mod): Mod { return Mod(this.number [2] other.number) } }
The operator function for '%' is named rem, and the operator symbol is '%'.
Fill all three blanks to overload the '==' operator by defining the 'equals' function.
class Person(val name: String) { override fun [1](other: Any?): Boolean { if (other !is Person) return false return this.name [2] other.name } operator fun [3](other: Person) = this == other }
The 'equals' function overrides '==' behavior, and inside it we use '==' to compare names. The operator function 'equals' is also used for operator overloading.