5 ms·
Yeah, its cute but it doesn't provide exhaustiveness testing which is what the Google guide is concerned about. I think Scala came up with a neat way to work t
by jeremyjh 11y ago
Yeah, its cute but it doesn't provide exhaustiveness testing which is what the Google guide is concerned about. I think Scala came up with a neat way to work that into an OO model with its sealed attribute. A sealed case class can't be extended past its original source file, so its inheritance hierarchy is fixed. Pattern matches on a sealed case class will warn for lack of exhaustiveness just like matches on ADTs do in Haskell, Rust etc.
- Someone 11y agoFor the language history buffs: sealed classes aren't a Scala invention. Dylan had them, too (at the library, rather than the source level. http://opendylan.org/books/dpg/perform.html http://opendylan.org/books/dpg/perform.html) (Better language history buffs than me, feel free to show prior art)
- steveklabnik 11y agoSmall note: non-exhaustive patterns are an error in Rust, not a warning.