Scala Sealed

A simple new keyword today

It is not possible to illustrate its main function using Scastie, so if you would like to learn more you will have to read the description snippet below. I am sorry about that.

We are reusing a lot of feature we saw in the past for this SKB. Everything should look familiar except the new keyword sealed

sealed is related to Object Oriented Programming and more specifically about inheritance.

The keyword sealed allows you to block inheritance if it is not within the same file. If you define a sealed trait or abstract class ( it works for both the exact same way ), you will only be able to extends this trait within this file.

This is the reason why it is hard to illustrate it within Scastie since everything is just one worksheet.

It is very useful when you want to describe something which have finite options. We are going to learn more about a very specific use case in the next SKB.

Reveal more information and clues
Load Exercise