title: Kotlin data class optional variable
body: <pre><code>data class Student(
      val id: Int?,
      val firstName: String?,
      val lastName: String?,
      val hobbyId: Int?,
      val address1: String?,
      val address2: String?,
      val created: String?,
      val updated: String?,
      ...
  )
  </code></pre>
  
  <p>I have like above data class, and I want to create a Student instance with only first name and last name.
  So If I run this,</p>
  
  <pre><code>// creating a student 
  Student(
      firstName = "Mark"
      lastName = "S"
  )
  </code></pre>
  
  <p>I will get <strong>No value passed for parameter 'id' ...</strong> errors.</p>
  
  <p>To avoid that, I modified the Student class like this,</p>
  
  <pre><code>data class Student(
      val id: Int? = null,
      val firstName: String? = null,
      val lastName: String? = null,
      val hobbyId: Int? = null,
      val address1: String? = null,
      val address2: String? = null,
      val created: String? = null,
      val updated: String? = null,
      ...
  )
  </code></pre>
  
  <p>But it looks so ugly. </p>
  
  <p>Is there any better way?</p>