With the current way LossyArray was set up, we were only able to access the array elements within the element var inside of the LossyArray. This meant that if we wanted to use any methods on our Lossy array, you'd need to access .element, like so:
List {
ForEach(user.loginData.elements, id: \.self) { item in
Text("Location: \(item.location)")
}
}
It was a really straightforward fix, only needing to conform LossyArray to Random Access Collection. Now, we can use LossyArrays the same way we'd use standard arrays throughout our code, after they've been decoded, like so:
List {
ForEach(user.loginData, id: \.self) { item in
Text("Location: \(item.location)")
}
}
With the current way
LossyArray
was set up, we were only able to access the array elements within theelement
var inside of the LossyArray. This meant that if we wanted to use any methods on our Lossy array, you'd need to access.element
, like so:It was a really straightforward fix, only needing to conform LossyArray to
Random Access Collection
. Now, we can use LossyArrays the same way we'd use standard arrays throughout our code, after they've been decoded, like so:You can find even more about this in #113!