Dhruv Singh
05/16/2025, 12:49 PMstruct HeadlessPaymentOptionsResponse: Codable, Equatable {
let param2: String
let param1: String
}
cc @chandilsachinWout Werkman
05/16/2025, 1:28 PMSelf, and there is there are no constructs such as implicit conformance or automatically generated members.
Because of lack of static interface members, in Kotlin we don't have Codable. And because of JVM, sadly every type is kind of Equatable (every class inherits Any, which has fun equals(other: Any?)).
If you would try to make your own Equatable, that would be impossible because of lack of Self type (there's a hack to kind of get this self type, but it's not even worth mentioning)
So I can't really show your example, but I'll show an example with Sequence from Swift instead.
interface Sequence<Element> { // Closest equivalent to Swift's `Sequence` protocol.
fun makeIterator(): Iterator<Element>
}
class MySingletonSequence<T>(private val item: T) : Sequence<T> {
fun makeIterator(): Iterator<T> = ...
}chandilsachin
05/18/2025, 3:50 PMstruct (Value Type) can conform to a Codable protocol.
Does KMM allows us to create similar construct (like Interface, a closest construct) which Struct can conform?
AFAIK, KMM would expose an interface (Reference type), which a struct (Value type) can't conform/implement. Pls Correct me if I am wrong.Wout Werkman
05/19/2025, 8:35 AM