On Tue, Apr 26, 2016 at 1:56 PM, David P. Sanders <
dpsa...@gmail.com> wrote:
>
>
> 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?
You need to pass in the type of the argument, not the argument itself,
to methodswith
julia> @enum FRUIT apple=1 pear=2
julia> methodswith(Type{FRUIT})
5-element Array{TypeMapEntry,1}:
convert(::Type{FRUIT}, x::Integer) at Enums.jl:79
instances(::Type{FRUIT}) at Enums.jl:86
typemax(x::Type{FRUIT}) at Enums.jl:83
typemin(x::Type{FRUIT}) at Enums.jl:82
writemime(io::IO, ::MIME{symbol("text/plain")}, ::Type{FRUIT}) at Enums.jl:103