Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I think you're thinking of `record` classes? Sealed classes are about constraining inheriting or implementing to only approved types - using sealed is pointless without overriding of some kind. Unlike in some other languages, where sealed is closer to java's final classes, i.e. stopping inheritance.


In Kotlin, I use sealed classes as a substitute for union types, and that means for the most part they have no functions.


If they are like Scala's I do mean sealed.


The only thing I can find on Scala with "sealed" is for exhaustive pattern-matching on types, which 1) broadly matches Java, and 2) has nothing to do with data-only objects at all. Sealing and methods are entirely orthogonal.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: