I have a function with kotlin and i like to call s...
# kotlin-native
d
I have a function with kotlin and i like to call specific platform code from there. Is possible to import both platform libraries? I need a conditional to check which platform is running?
o
it is possible using multiplatform (MPP), doing it from the same file is not possible
n
expect and actual ?
d
let me show an example var miau = "whatever" // here db is a specific platform i want to know how to be able to give the correct one db.insert(miau) // continues common code
s
Definitely read up on multiplatform. Basically you'll create a project of common code and then a number of source sets for each specific platform. Those source sets will have platform specific dependencies. The common code can depend on classes defined in platform source sets by using the expect/actual mechanism to create stubs and implementations.
✔️ 1