Enum Unions


#1

Allow enum types to be unionable.

For example:

enum InputOptions
  Required
  Optional
  NoValue
end

mode = InputOptions::Required | InputOptions::NoValue

mode.required? # => true
mode.no_value? # => true

The use case for this, for this example, would have having a paramater that has to be present but does not have a value associated with it. e.x. ./myApp --flag would be valid, but ./myApp --flag=123 would not be.


#2

Just stick @[Flags] at the top of the enum definition: https://play.crystal-lang.org/#/r/5yry


#3

Ah perfect, i missed the blurb about that in the docs :frowning: