Skip to content

Instantly share code, notes, and snippets.

@skydoves
Created February 17, 2026 01:14
Show Gist options
  • Select an option

  • Save skydoves/219afb418ae877e6ec3e5d633d8856e1 to your computer and use it in GitHub Desktop.

Select an option

Save skydoves/219afb418ae877e6ec3e5d633d8856e1 to your computer and use it in GitHub Desktop.
Value Class Boxing Scenarios in Kotlin
val id1: Any = UserId("abc") // Stored as Any, forces boxing
val id2: UserId? = UserId("def") // Nullable type can force boxing
val listOfIds = listOf(UserId("1")) // Generic collection, forces boxing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment