title: Same property name and primary constructor parameter name in Kotlin
body: <p>I'm little confused how kotlin is managing the property name and the primary constructor parameter name. If I wrote the same property name and the parameter name then kotlin compiler gives an error.</p>
  
  <pre><code>class Student(name : String, roll : Int){
      val name: String
  
      init {
          name = "Asif"
      }
  }
  </code></pre>
  
  <p>It gives this error. </p>
  
  <pre><code>&gt; Error:(9, 5) Kotlin: Property must be initialized or be abstract
  &gt; Error:(12, 9) Kotlin: Val cannot be reassigned
  </code></pre>
  
  <p>But when I change the name of the property <code>val name : String</code> or the changing the name of the parameter of the primary constructor <code>name : String</code> then the code will work and compile.</p>
  
  <p>This will work or compile fine.</p>
  
  <pre><code>class Student(pName : String, roll : Int){
      val name: String
  
      init {
          name = "Asif"
      }
  }
  </code></pre>
  
  <p>What is the reason behind this? Why we can't have the same primary constructor's parameter name and the property name?</p>