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

Here’s a little Scala 3 (Dotty) enum match/case expression example:

// a Scala 3 (Dotty) enum
enum Suit {
    case Clubs, Diamonds, Hearts, Spades

object DottyEnumTest1 extends App {

    import Suit._
    // an enum in a match expression
    def printEnum(suit: Suit) = suit match {
        case Clubs => println("clubs")
        case Diamonds => println("diamonds")
        case Hearts => println("hearts")
        case Spades => println("spades")


This works as of August 22, 2019 with what appears to be Dotty 0.17. I don’t think it worked earlier this summer, as I had made a note to ask if Scala 3 enums would eventually work with match expressions. So this is cool.