Function Reference to Overloaded functions


#1

When a function is referenced like

val temp = Int::div

The compiler shows an error
"Overload resolution ambiguity:
public final operator fun div(other: Byte): Int defined in kotlin.Int
public final operator fun div(other: Double): Double defined in kotlin.Int
public final operator fun div(other: Float): Float defined in kotlin.Int
public final operator fun div(other: Int): Int defined in kotlin.Int
public final operator fun div(other: Long): Long defined in kotlin.Int
public final operator fun div(other: Short): Int defined in kotlin.Int"

How to solve this error?


#2

Specify the type that you expect: val temp: Int.(Int) -> Int = Int::div