Skip to content
This repository was archived by the owner on Jun 5, 2023. It is now read-only.
This repository was archived by the owner on Jun 5, 2023. It is now read-only.

provide scala.Numeric + Range for enumerations? #145

@bishabosha

Description

@bishabosha

from https://twitter.com/ppurang/status/1317827002070597634

enum Rank {
  case Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Jack, Queen, King, Ace 
}

enum Suit {
  case  Clubs, Diamonds, Hearts, Spades
}

case class Card(suit: Suit, rank: Rank)

import Rank._
import Suit._

val Deck = for {
  suit <- Clubs to Spades
  rank <- Two to Ace
} yield Card(suit, rank)

alternative: a third party library could do this with derivation

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions