I'm just learning Kotlin as a fun side-project for Project Euler. I just started literally 5 minutes ago, in IntelliJ IDEA.
I have this code:
fun Number.isMultipleOf(n: Number): Boolean {
return this % n == 0
}
fun main(args: Array<String>){
println(10.isMultipleOf(5))
}
The compile error is this:
Kotlin: Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:
@Deprecated @InlineOnly public inline operator fun BigDecimal.mod(other: BigDecimal): BigDecimal defined in kotlin
I'm experienced in Java, Python, C++ and Swift so I figured Kotlin shouldn't be that much of a challenge. But WTF is a "receiver type"?
How can I fix this compile error while getting the desired functionality out of the Number
class extension?