How to include module for a enum?

module A
end

enum B
  Bob
end

enum currently does not support including a module.
There is a feature request for this, tracked at Add include and extend to Enum · Issue #8946 · crystal-lang/crystal · GitHub

Depending on what you actually need this for, you could consider macros as a workaround for sharing code between multiple types.

1 Like