Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juanchosaravia/cf7a114c5672a283345f145c79bfb722 to your computer and use it in GitHub Desktop.
Save juanchosaravia/cf7a114c5672a283345f145c79bfb722 to your computer and use it in GitHub Desktop.
inline fun <reified T : Parcelable> createParcel(
crossinline createFromParcel: (Parcel) -> T?): Parcelable.Creator<T> =
object : Parcelable.Creator<T> {
override fun createFromParcel(source: Parcel): T? = createFromParcel(source)
override fun newArray(size: Int): Array<out T?> = arrayOfNulls(size)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment