lundi 19 juin 2017

Why does == and equals produce different results?

Executing the following code:

inline fun <reified> R> foorbar() {
    println(R::class == Double::class)
    println(R:class.equals(Double::class))
}

fun main(args: Array<String>) {
    foobar<Double>()
}

Produces the following output:

false
true

Why is there a difference between == and equals in this case? IntelliJ itself is suggesting that I replace the equals call with ==. Also, I could have sworn this code using == was working in the past.

Using kotlin version 1.1.0-rc91





Aucun commentaire:

Enregistrer un commentaire