Kotlin Sealed Class – An Explanation
Today I came across the Kotlin Sealed Class which I had never heard of before. After some research, I found that this concept is nothing new and is also available in Scala for example. So, yet another Scala feature JetBrains considered relevant and suitable for Kotlin? I like that :) Read this post if you're interested in more Kotlin features. Actually, this is a quite simple feature, which I'm going to explain in the following. Kotlin Sealed Class - Feature Explanation A sealed class can be subclassed and may include abstract methods, which means that sealed classes are abstract implicitly, although the documentation doesn't clearly say so. To actually make a class "sealed" we have to put the sealed modifier before its name, as we can see here: sealed class MyClass Restriction The…