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

Kotlin 1.5 preview

3295d80faee461db1093982361256fe4?s=47 Panini
February 17, 2021

Kotlin 1.5 preview

3295d80faee461db1093982361256fe4?s=128

Panini

February 17, 2021
Tweet

Transcript

  1. Kotlin 1.5 preview Kotlin愛好会 vol.27

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

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

    https://zsmb.co/sealed-goodies-coming-in-kotlin-1-5/
  4. Sealed Class improvements

  5. 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
  6. Kotlin ~1.4 Sealed Class

  7. Kotlin ~1.4 Sealed Class

  8. Kotlin ~1.4 Sealed Class

  9. Kotlin 1.5+ Sealed Class • https://kotlinlang.org/docs/sealed-classes.html • Can be defined

    anywhere in the same package, and same module
  10. Sealed Interface

  11. 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
  12. Summary • Sealed Class is like super enum • Sealed

    Interface is like package private Interface • Kotlin 1.5 looks good!
  13. Have a nice Kotlin!