Reputation: 23
I'm trying to use kotlin.math.abs in a util.kt file, but the following code results in an "unused import" warning on the import statement and an unresolved reference where I use abs in the code.
import kotlin.math.abs
fun fuzzyEquals(a: Double, b:Double, epsilon: Double= 0.001) = abs(a-b) < epsilon
I'm using IntelliJ and gradle to organize the project. I'm on Intellij 2018.2.5 with Kotlin 1.3.0.
The folling code does work, so I don't think it's a problem with Kotlin as a whole
import kotlin.sequences.find
fun test() = listOf(1,2).find{it==1}
Upvotes: 2
Views: 3659
Reputation: 23144
The functions from kotlin.math
package can be unresolved by one of the following reasons:
dependencies
block of your build file.apiVersion
compiler option, which limits visible API to only available in the specified version, can be set. Check whether you have this option in Gradle build file and also check the effective version in the Kotlin facet of your module in IntelliJ project structure.Upvotes: 1