Compilation issue

Report a typo

Here is a class implementing Parcelable interface. But something is missing there! Type in the missing line above the CREATOR property to make this snippet work.

class Person(
    val id: String?,
    val name: String?,
    val age: Int,
) : Parcelable {
    override fun describeContents(): Int {
        return 0
    }

    override fun writeToParcel(dest: Parcel, flags: Int) {
        dest.writeString(id)
        dest.writeString(name)
        dest.writeInt(age)
    }

    companion object {
        // Something is missing here!
        val CREATOR: Parcelable.Creator<Person> = object : Parcelable.Creator<Person> {
            override fun createFromParcel(parcel: Parcel): Person {
                return Person(parcel.readString(), parcel.readString(), parcel.readInt())
            }

            override fun newArray(size: Int): Array<Person?> {
                return arrayOfNulls(size)
            }
        }
    }
}
Enter a short text
___

Create a free account to access the full topic