title: What are different between Code 1 and Code 2 in Kotlin?
body: <p>The code 1 is from a sample project, and I modify some code and change it to code 2, and the code 2 can also run correctly.</p>
  
  <p>What are different between Code 1 and Code 2 in Kotlin? Thanks!</p>
  
  <p><strong>Code 1</strong></p>
  
  <pre><code>data class ForecastList(val id: Long, val city: String, val country: String, val dailyForecast: List&lt;Forecast&gt;) {
  
      val size: Int
          get() = dailyForecast.size
  
      operator fun get(position: Int) = dailyForecast[position]
  }
  </code></pre>
  
  <p><strong>Code 2</strong></p>
  
  <pre><code>data class ForecastList(val id: Long, val city: String, val country: String, val dailyForecast: List&lt;Forecast&gt;) {
  
      val size: Int = dailyForecast.size
  
      operator fun get(position: Int) = dailyForecast[position]
  }
  </code></pre>