Hi folks, quick question. How come i can import java.util.UUID in commonMain?
In commonMain:
Copy code
public expect class UUID
In jvmMain
Copy code
public actual typealias UUID = java.util.UUID
In another part in commonMain:
Copy code
import java.util.UUID
public data class Account(
public val uuid: UUID,
public val number: String,
public val firstName: String,
public val lastName: String,
public val identityKey: String
)
Actually i was trying to play with expect and actual
g
Grégory Lureau
03/03/2022, 11:39 AM
Oh ok, clearer after you edited the message. You don't want to import java.util; you want to import your
expect
UUID
g
George
03/03/2022, 11:41 AM
Yup that's what i thought, thanks for the help. For some reason intelij did not import automatically my expect . So i just typed manual the import and it worked lol . Still pretty new to KMM 🙂
George
03/03/2022, 11:41 AM
Another quick question is it ok to declare my actual impl with typealis as i did in jvmmain?
g
Grégory Lureau
03/03/2022, 11:44 AM
Yes it's totally fine.
You have some constraints when using a typealias, the method needs to match the
expect
class, so if you support more than just jvm, you will probably need a mapping class instead of just a typealias at some point.