title: Kotlin function syntax
body: <p>I'm doing the Kotlin Koans tests in order to familiarise myself with Kotlin. In a certain test I have to override the <code>compareTo</code> method. In the first case everything work as intended</p>
  
  <pre><code>data class MyDate(val year: Int, val month: Int, val dayOfMonth: Int) {
  
      operator fun compareTo(other: MyDate)= when {
          year != other.year -&gt; year - other.year
          month != other.month -&gt; month - other.month
          else -&gt; dayOfMonth - other.dayOfMonth
      }
  
  }
  </code></pre>
  
  <p>Now in the second case where I'm writing the <code>compareTo</code> a little bit differently I get a ton of compilation errors. </p>
  
  <pre><code>data class MyDate(val year: Int, val month: Int, val dayOfMonth: Int) {
  
  
       operator fun compareTo(other: MyDate){
  
          when {
              year != other.year -&gt; return year - other.year
              month != other.month -&gt; return month - other.month
              else -&gt; return dayOfMonth - other.dayOfMonth
         }
       }
  
  
   }
  </code></pre>
  
  <p>First of all, at the operator keyword, I get an error:</p>
  
  <blockquote>
    <p>'operator' modifier is inapplicable on this function: must return Int</p>
  </blockquote>
  
  <p>and in the returns I get</p>
  
  <blockquote>
    <p>Type mismatch: inferred type is Int but Unit was expected</p>
  </blockquote>
  
  <p>I cannot understand why these errors occur since the first implementation returns the same <code>Int</code>s</p>