title: Kotlin: return a value on button click
body: <p>I'm just starting out on learning Kotlin, and I'm currently making a simple Quiz application for Android. The user can choose an answer with four buttons which are stored in an array. The program contains a functions which is supposed to check if the correct button is clicked and return a corresponding boolean:</p>
  <pre><code>fun checkAnswer (solution: Int): Boolean {
      for (z in answerButtons.indices) {
          answerButtons[z].setOnClickListener{
              return z == solution
          }
      }
  }
  </code></pre>
  <p>Now I know that this <code>return</code> doesn't work, but I just can't find a way to return a value depending on which button is clicked. If anyone could help me here, I'd be very grateful. Thanks!</p>