Using Fire .2485.
If I create a struct, add it to an array or set it as a dictionary key, and then try to find it in the array using
indexOf() or get a dictionary value using struct as a key, like
guard let someValue = dict[someStructAsKey], it’s never found, meaning that for array
indexOf() returns -1, and for dictionary
guard let returns
It works for array if I override
func equals(), so I assume I would have to override
hashCode() to use dictionary?
AFAIK in Java structs are also compared by pointer ref, same as classes? So, can this even be solved on a compiler level to be more swift-like, or is overriding
hashCode() the only way to go?
From what I could figure out looking at the source of swift base library on RO github, Equatable and Comparable are just stubs, right?
Test project attached.
AndroidDictArrayTest.zip (144.7 KB)