why does == creates compilation error on different types in Kotlin

Viewed 129

The following code cannot be compiled:

if ("2" == 3) {
  //do something
}

Error: Kotlin: Operator '==' cannot be applied to 'String' and 'Int'

However, Kotlin docs say this is structural equality and is translated to a?.equals(b) ?: (b === null): https://kotlinlang.org/docs/reference/equality.html .

So what is really going on here? How does it work?

1 Answers
Related