diff --git a/slides/sources/progfun1-3-5.md b/slides/sources/progfun1-3-5.md index 76852496eb731c5206c237c71844debb7a265346..1f7bcac21e7bc11032ab2c972262912faff88aaa 100644 --- a/slides/sources/progfun1-3-5.md +++ b/slides/sources/progfun1-3-5.md @@ -5,8 +5,8 @@ Enums: Motivation ================= -We have seen that case classes *aggregate several values* into a single abstraction. -For instance, the `Rational` case class aggregates a numerator and a denominator. +We have seen that classes can *aggregate several values* into a single abstraction. +For instance, the `Rational` class aggregates a numerator and a denominator. Conversely, how could we define an abstraction *accepting alternative values*? @@ -57,7 +57,7 @@ It is possible to enumerate all the values of an enum by calling the \begin{tabular}{ll} \verb@Color.values@ \wsf Array(Red, Green, Blue, Magenta) \\ \verb@val c = Color.Green@ \wsf c: Color = Green \\ - \verb@p == Color.values(1)@ \wsf true + \verb@c == Color.values(1)@ \wsf true \end{tabular} Discriminate the Values of an Enumeration @@ -83,7 +83,7 @@ Match Syntax - Default cases are written with an underscore, e.g. ~~~ - def isPrimary(color: Color): Boolean = paradigm match + def isPrimary(color: Color): Boolean = color match case Magenta => false case _ => true ~~~