I’m trying the kotlin REPL in Intellij in my macbo...
# getting-started
d
I’m trying the kotlin REPL in Intellij in my macbook pro for the first time, and running into an issue when trying to do something like.
Copy code
min(10, 2)
error: unresolved reference. None of the following candidates is applicable because of receiver type mismatch: 
public fun <T : Comparable<TypeVariable(T)>> Array<out TypeVariable(T)>.min(): TypeVariable(T) defined in kotlin.collections
public fun Array<out Double>.min(): Double defined in kotlin.collections
public fun Array<out Float>.min(): Float defined in kotlin.collections
public fun ByteArray.min(): Byte defined in kotlin.collections
Copy code
import kotlin.collections
 
 min(10, 2)
error: packages cannot be imported
import kotlin.collections
j
The top-level
min
function needs to be imported I believe. It should be from
kotlin.math
. You're not trying to use the
.min()
extension function on collections here
d
Copy code
import kotlin.math
 
 min(10, 2)
error: packages cannot be imported
import kotlin.math
j
You need
import kotlin.math.*
or
import kotlin.math.min
, you cannot import the package itself
d
ah yes that’s the syntax thanks @Joffrey
j
No problem!
Also, note that
kotlin.collections.*
is imported by default AFAIR, so you'll never need to import it. That's why the initial error already knew about these extension functions on collections
👍 1
e
minOf
does not require an import
👍 2
j
Ah yes,
minOf
is from
kotlin.comparisons
which is also a default import