Anybody had a problem when Kotlin couldn't cast Sw...
# multiplatform
m
Anybody had a problem when Kotlin couldn't cast Swift
Int64
to
KotlinLong?
, example in thread.
Swift code:
Copy code
let long: Int64 = 5
kotlinFun(value: long)
Kotlin code:
Copy code
fun kotlinFun (value: Long?) {}
This works:
Copy code
let long: Int64 = 5
kotlinFun(value: KotlinLong(value: long))
But if you have
Int64?
then you have to do something like this:
Copy code
let long: Int64? = 5
if long == nil {
    kotlinFun(value: nil)
} else {
    kotlinFun(value: KotlinLong(value: long!))
}
The same thing happens with
Int
(and other numeric types), but not with
String
Any better solutions?
e
I would expect something like
Copy code
kotlinFun(value: long.map { KotlinLong(value: $0) })
to work, not sure if there's a simpler way