Slide 1

Slide 1 text

Kotlin 1.5 preview Kotlin愛好会 vol.27

Slide 2

Slide 2 text

About Me ● Matthew Vern / Panini ● Twitter: @panini_ja Github: panpanini ● Mercari, Inc ● Android Engineer (US) ● Kotlin可愛い

Slide 3

Slide 3 text

Summary ● Sealed Class improvements ● Sealed Interface ● Reference: https://zsmb.co/sealed-goodies-coming-in-kotlin-1-5/

Slide 4

Slide 4 text

Sealed Class improvements

Slide 5

Slide 5 text

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

Slide 6

Slide 6 text

Kotlin ~1.4 Sealed Class

Slide 7

Slide 7 text

Kotlin ~1.4 Sealed Class

Slide 8

Slide 8 text

Kotlin ~1.4 Sealed Class

Slide 9

Slide 9 text

Kotlin 1.5+ Sealed Class ● https://kotlinlang.org/docs/sealed-classes.html ● Can be defined anywhere in the same package, and same module

Slide 10

Slide 10 text

Sealed Interface

Slide 11

Slide 11 text

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

Slide 12

Slide 12 text

Summary ● Sealed Class is like super enum ● Sealed Interface is like package private Interface ● Kotlin 1.5 looks good!

Slide 13

Slide 13 text

Have a nice Kotlin!