The following is my idea of writing enums that are better than the macro
because they give you a typesafe way of passing them to a
functionbaremodule EnumName immutable enumname x::UInt8 end
const Value_A = enumname(0) const Value_B = enumname(1)end# usage
examplebaremodule Color immutable color x::UInt8 end const
Red = color(1) const Green = color(2) const Blue = color(3) const
White = color(4) const Black = color(5)endfunction
testColor(c::Color.color) println("A color was
passed")endtestColor(Color.Red)
- [julia-users] Proposed solution for writing Enums Paul Sorensen
- Re: [julia-users] Proposed solution for writing Enum... Stefan Karpinski
- Re: [julia-users] Proposed solution for writing ... Stefan Karpinski
- Re: [julia-users] Proposed solution for writ... Brian Rogoff
- Re: [julia-users] Proposed solution for ... Evan Fields
- Re: [julia-users] Proposed solution... Jacob Quinn
- Re: [julia-users] Proposed solution for ... Stefan Karpinski
- Re: [julia-users] Proposed solution... Brian Rogoff
- Re: [julia-users] Proposed solu... Stefan Karpinski
