title: Android parcelable - write nullable long
body: <p>I have my parcelable class Article:</p>
  
  <pre><code>class Article : Parcelable {
  
      var image: Long? = null
      var category: String? = null
      var videos: String? = null
  
      constructor(data: JSONObject) {
          if (condition) image = 50000L
          category = data.getString("category")
          videos = data.getString("videos")
      }
  
      private constructor(parcel: Parcel) {
          image = parcel.readLong()
          category = parcel.readString()
          videos = parcel.readString()
      }
  
      override fun writeToParcel(dest: Parcel, flags: Int) {
          dest.writeLong(image) // error here
          dest.writeString(category)
          dest.writeString(videos)
      }
  
      override fun describeContents(): Int = 0
  
      companion object {
          @JvmField val CREATOR: Parcelable.Creator&lt;Article&gt; = object : Parcelable.Creator&lt;Article&gt; {
              override fun createFromParcel(parcel: Parcel): Article = Article(parcel)
              override fun newArray(size: Int): Array&lt;Article?&gt; = arrayOfNulls(size)
          }
      }
  }
  </code></pre>
  
  <p>But my class is getting a type mismatch at writing the image var. It is expecting a Long and not a Long?. I do understand that this could be solved if I do something like this:</p>
  
  <pre><code>dest.writeLong(image!!)
  </code></pre>
  
  <p>But the problem is that this var could really be null on my context.
  I don't want either to define my image var as a default value like 0. I really want the var to remain nullable.</p>
  
  <p>Is there any way to write a nullable var?</p>