~/talk

Kotlin variance modifiers and Covariant Object Nothing pattern

Talkat AndroidMakers by droidcon 2025 · on Friday, 2025-04-11· at 10:15· [kotlin]
slides:none on file

Explains the concrete claim that making generics covariant and using Nothing as a placeholder produces single reusable instances (the Covariant Nothing Object pattern) and its sibling for sealed generics (Covariant Nothing Class). Shows the standard library listOf<Nothing> emptyList implementation, demonstrates Arrow-style Either using Nothing, measures the payoff (avoids thousands of allocations per second), and walks limitations: in/out positions, unsafe variance escapes, and why arrays remain invariant compared with Java.

AI-written summary · about

  1. 0:00Variance modifiers intro
  2. 2:08Generic type modifiers
  3. 6:07Variance use cases
  4. 14:15Covariant Nothing Object
  5. 23:16Variance limitations
  6. 31:32Further resources
  7. 31:57Q&A
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.