A Scala 3 (Dotty) enum match/case expression example

Here’s a little Scala 3 (code-named “Dotty”) enum match/case expression example:

enum Suit:
    case Clubs, Diamonds, Hearts, Spades

@main def dottyEnumTest =

    import Suit._

    def printEnum(suit: Suit) = suit match
        case Clubs    => println("clubs")
        case Diamonds => println("diamonds")
        case Hearts   => println("hearts")
        case Spades   => println("spades")

    printEnum(Clubs)
    printEnum(Diamonds)
    printEnum(Hearts)
    printEnum(Spades)

I don’t know how other people feel, but I really enjoy using the new Scala/Dotty syntax without curly braces.