https://kotlinlang.org logo
#getting-started
Title
# getting-started
p

poohbar

02/20/2021, 8:22 PM
how to call a java function called
to
from Kotlin? it keeps trying to use the
Pair
extension 🤔
y

Youssef Shoaib [MOD]

02/20/2021, 8:34 PM
use an import alias like this:
import <http://com.javaCode.to|com.javaCode.to> as javaTo
p

poohbar

02/20/2021, 8:44 PM
@Youssef Shoaib [MOD] wicked!
it won't let me import that 🤔 ..
Kotlin: Cannot import 'to', functions and properties can be imported only from packages or objects
y

Youssef Shoaib [MOD]

02/20/2021, 8:48 PM
hmmm, make sure you fully qualify it i.e. with the full package like this
import <http://com.example.x.y.z.to|com.example.x.y.z.to> as javaTo
d

Denis

02/20/2021, 8:57 PM
maybe you need to backtick it `import package.
to
as javato` ? (I've no idea if it works)
n

nanodeath

02/20/2021, 9:04 PM
or `javaInstance.`to`(arg)`
1
3 Views