File tree Expand file tree Collapse file tree 1 file changed +3
-4
lines changed
Structuring Information/Defining Alternatives With Sealed Traits Expand file tree Collapse file tree 1 file changed +3
-4
lines changed Original file line number Diff line number Diff line change @@ -70,9 +70,9 @@ Having defined `Symbol` as a sealed trait gives us the guarantee that
7070the possible case of symbols is fixed. The compiler can leverage this
7171knowledge to warn us if we write code that does not handle * all*
7272the cases:
73- {{{
73+ ``` scala
7474def unexhaustive (): Unit = {
75- sealed trait Symbol
75+ sealed trait Symbol
7676case class Note (name : String , duration : String , octave : Int ) extends Symbol
7777case class Rest (duration : String ) extends Symbol
7878
@@ -81,8 +81,7 @@ def nonExhaustiveDuration(symbol: Symbol): String =
8181 case Rest (duration) => duration
8282 }
8383}
84- }}
85-
84+ ```
8685If we try to run the above code to see how the compiler informs us that
8786we don’t handle all the cases in ` nonExhaustiveDuration ` .
8887
You can’t perform that action at this time.
0 commit comments