title: What is firstIndex in SwiftUI - Swift
body: <p>While following the Apple tutorial about SwiftUI I found this:</p>
  
  <pre><code>1| var landmarkIndex: Int {
  2|    userData.landmarks.firstIndex(where: { $0.id == landmark.id })!
  3| }
  </code></pre>
  
  <p>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."</p>
  
  <p>I can't understand what is firstIndex and what I am accessing by writing "$0.id == landmark.id"
  Why am I creating this var? </p>
  
  <p>Thank you so much - 
  Nico</p>
  
  <p><a href="https://developer.apple.com/tutorials/swiftui/handling-user-input" rel="nofollow noreferrer">Apple tutorial about SwiftUI</a></p>