Skip to content

Latest commit

 

History

History
38 lines (27 loc) · 1.02 KB

Collections with custom types.md

File metadata and controls

38 lines (27 loc) · 1.02 KB

Collections with custom types

Collections with elements of custom types do not require additional mappings.

Explanations

Let the following code be declared on the Kotlin side:

//CollectionsWithCustomTypesData.kt

data class NotPrimitiveType(
    val item: String
)

fun notPrimitiveTypeList(list: List<NotPrimitiveType>): List<NotPrimitiveType> {
    return list
}

fun notPrimitiveTypeSet(set: Set<NotPrimitiveType>): Set<NotPrimitiveType> {
    return set
}

fun notPrimitiveTypeMap(map: Map<String, NotPrimitiveType>): Map<String, NotPrimitiveType> {
    return map
}

On the Swift side, collections with custom data types can be used without special mappings:

let myList: [NotPrimitiveType] = CollectionsWithCustomTypesDataKt.notPrimitiveTypeList(list: inList)
let mySet: Set<NotPrimitiveType> = CollectionsWithCustomTypesDataKt.notPrimitiveTypeSet(set: inSet)
let myMap: [String: NotPrimitiveType] = CollectionsWithCustomTypesDataKt.notPrimitiveTypeMap(map: inMap)  

Table of contents