Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Kotlin 1.5 preview

Avatar for Panini Panini
February 17, 2021

Kotlin 1.5 preview

Avatar for Panini

Panini

February 17, 2021
Tweet

More Decks by Panini

Other Decks in Programming

Transcript

  1. About Me • Matthew Vern / Panini • Twitter: @panini_ja

    Github: panpanini • Mercari, Inc • Android Engineer (US) • Kotlin可愛い
  2. Summary • Sealed Class improvements • Sealed Interface • Reference:

    https://zsmb.co/sealed-goodies-coming-in-kotlin-1-5/
  3. Kotlin ~1.4 Sealed Class • https://kotlinlang.org/docs/sealed-classes.html • Enum with super

    power • Can be defined either nested, or in the same file • https://qiita.com/kikuchy/items/ad89a12029082be8d218
  4. Kotlin 1.5+ Sealed Interface • https://kotlinlang.org/docs/sealed-classes.html#sealed-interfaces • Implementations must be

    declared in same package and same module • Can restrict implementers to inside a single module ◦ Useful for hiding implementation details • YouTrack: https://youtrack.jetbrains.com/issue/KT-22286
  5. Summary • Sealed Class is like super enum • Sealed

    Interface is like package private Interface • Kotlin 1.5 looks good!