• bitcrafter@programming.dev
    link
    fedilink
    arrow-up
    0
    ·
    1 month ago

    Could someone explain to me what the value is in making it really easy to initialize an enum class with a value that is not one of the enumerated values?

    • Paul@feddit.dk
      link
      fedilink
      arrow-up
      0
      ·
      edit-2
      1 month ago

      Good question. My response would be: only where it is not used as an enum. The example in the article is one example (although I’ve never seen that idiom in the wild) or for doing things like bitfields (the opposite of the to_underlying section).