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?
Please make sure that you add the id 'kotlin-android-extensions' line on the build. gradle file that's inside your app module. Once you sync the Gradle build, the error should disappear.
From the main menu, select File | Project Structure | Project Settings | Project. If the necessary SDK is already defined in IntelliJ IDEA, select it from the SDK list. If the SDK is installed on your computer, but not defined in the IDE, select Add SDK | 'SDK name', and specify the path to the SDK home directory.
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")
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With