The sealed keyword in Scala restricts the inheritance of a class or trait to the same file in which it is defined, providing a balance between open inheritance and final restrictions.
The sealed modifier allows controlled inheritance within a limited scope, which is particularly useful for exhaustive pattern matching in application logic.
Unlike the final modifier, which completely prevents extension, the sealed keyword offers developers the flexibility to define a closed hierarchy within specific files.
Public classes in Scala are open for extension, which means they can be inherited by any other class unless explicitly restricted.
Collection
[
|
...
]