Skip to content

Latest commit

 

History

History
43 lines (27 loc) · 1.16 KB

File metadata and controls

43 lines (27 loc) · 1.16 KB

Data classes

Some autogenerated functions are converted to Swift: copy to doCopy, equals to isEquals, toString to description. Additional features, like destructuring, are not supported.

Explanations

Let's describe the usual data class in Kotlin:

data class DataClass(
    val param1: String,
    val param2: Int,
    val param3: Boolean
)

Function copy

The function copy is converted to Swift with the name doCopy, and works similarly to the function in Kotlin, but there is an inconvenience with the need to specify all the function arguments.

Function equals

Comparing two instances of a data class works similarly to Kotlin, including comparing collections. The equivalent function is isEquals in Swift.

Function toString

When using a data class object in a line, the output is the same as in Kotlin:

let data = DataClass(param1: "abc", param2: 123, param3: true)
print("data = \(data)")

The equivalent function is description in Swift.

Destructuring

This feature is not supported.


---
[Table of contents](/README.md)