PacificNW_Lover
PacificNW_Lover

Reputation: 5374

IntelliJ IDEA - Kotlin: Unresolved reference: eq method

Am using IntelliJ IDEA 2019.1.2 (Ultimate Edition) with Kotlin (kotlinc-jvm 1.3.31) on macOS Mojave 10.14.5.

When I created a Kotlin JVM project and added a Kotlin file entitled "Nullability.kt" with the following code (extension function with a main() method):

fun List<Int>.allNonZero() = all { it > 0 }

fun main() {
    val list1 = listOf(1, 2, 3)
    list1.allNonZero() eq true
}

IntelliJ IDEA highlights "eq" in red and it states:

Kotlin: Unresolved reference: eq

How to resolve this from within IntelliJ IDEA?

Upvotes: 13

Views: 1907

Answers (1)

PacificNW_Lover
PacificNW_Lover

Reputation: 5374

Found it, inside the Coursera course, Kotlin has a Playground where the code is hidden but you can expand it and view it by clicking on the + sign.

infix fun <T> T.eq(other: T) {
    if (this == other) println("OK")
    else println("Error: $this != $other")
}

Upvotes: 22

Related Questions