While following the Apple tutorial about SwiftUI I found this:
1| var landmarkIndex: Int {
2| userData.landmarks.firstIndex(where: { $0.id == landmark.id })!
3| }
Inside the tutorial line 2 isn't explained so well, they only say: "You’ll use landmarkIndex when accessing or updating the landmark’s favorite status, so that you’re always accessing the correct version of that data."
I can't understand what is firstIndex and what I am accessing by writing "$0.id == landmark.id" Why am I creating this var?
Thank you so much - Nico