El martes, 26 de abril de 2016, 12:13:22 (UTC-4), Steven G. Johnson 
escribió:
>
>
>
> On Tuesday, April 26, 2016 at 11:07:45 AM UTC-4, Pieterjan Robbe wrote:
>>
>> Is it possible to export all values of an an enum defined inside a module?
>> That is, without rewriting all values after 'export'.
>>
>
> for s in instances(WindDirection)
>
>     @eval export $(symbol(s))
> end 
>


The instances function (that I didn't know about) doesn't seem to be shown 
by `methodswith` of the enumeration.
How could we improve this?

julia> @enum FRUIT apple=1 pear=2

julia> methodswith(FRUIT)
3-element Array{Method,1}:
 isless(::FRUIT, ::FRUIT) at Enums.jl:84
 print(::IO, ::FRUIT) at Enums.jl:89
 show(::IO, ::FRUIT) at Enums.jl:95

julia> methodswith(FRUIT, true)
5-element Array{Method,1}:
 convert{T<:Integer}(::Type{T<:Integer}, x::Enum) at Enums.jl:9
 isless(::FRUIT, ::FRUIT) at Enums.jl:84
 print(::IO, ::FRUIT) at Enums.jl:89
 show(::IO, ::FRUIT) at Enums.jl:95
 write(io::IO, x::Enum) at Enums.jl:11

julia> instances(FRUIT)
(apple::FRUIT,pear::FRUIT)

Reply via email to