title: Kotlin how to return a SINGLE object from a list that contains a specific id?
body: <p>Good day, i'm stuck figuring out how to get a single object from a list, i did google but all the topics show how to return a <code>List</code> with sorted objects or something similar.</p>
  
  <p>I have a <code>User Class</code></p>
  
  <pre><code>class User() {
  
      var email: String = ""
      var firstname:  String = ""
      var lastname: String  = ""
      var password: String  = ""
      var image: String  = ""
      var userId: String  = ""
  
      constructor(email:String,
                  firstname: String,
                  lastname: String,
                  password: String,
                  image: String, userId : String) : this() {
          this.email = email
          this.firstname = firstname
          this.lastname = lastname
          this.password = password
          this.image = image
          this.userId = userId
      }
  }
  </code></pre>
  
  <p>In java i would write something like</p>
  
  <pre><code> User getUserById(String id) {
          User user = null;
          for(int i = 0; i &lt; myList.size;i++;) {
              if(id == myList.get(i).getUserId())
              user = myList.get(i)
          }
          return user;
      }
  </code></pre>
  
  <p>How can i achieve the same result in kotlin?</p>