title: Kotlin - same condition: multiple if statements or one if statement
body: <p>In Kotlin you can use if statements kind of like ternary operators.</p>
  <p>We have the option to do something like this:</p>
  <pre><code>val x = if (isOdd) 1 else 2
  </code></pre>
  <p>but if we have multiple variables that need to be set based on some condition is it more correct to do it the old fashioned way like so:</p>
  <pre><code>val x: Int
  val y: Int
  val z: Int
  
  if (isOdd) {
      x = 1
      y = 3
      z = 5
  } else {
      x = 2
      y = 4
      z = 6
  }
  </code></pre>
  <p>or like this :</p>
  <pre><code>val x = if (isOdd) 1 else 2
  val y = if (isOdd) 3 else 4
  val z = if (isOdd) 5 else 6
  </code></pre>
  <p>the second way looks much cleaner to me, but I'd like to know if the first method would be computed faster since it only needs to calculate the condition once whereas the second way needs to check the condition 3 times.</p>
  <p>Is the second way actually slower or will it be optimized by the compiler?</p>