Different ways to declare Enum datatype in Julia-Lang -
is using @enum way declare julia enum datatype? if why?
it's (easy) way, yes. answer, (or, rather, always) in julia, can found looking @ source code. can bit scary @ first, used after while!
normally create object of given type, call type's constructor. might expect able do
enum(...)   and create object of type enum.
in case, however, enum abstract type, cannot that.
what @enum do, then? example manual is
julia> @enum fruit apple=1 orange=2 kiwi=3   this creates new type, called fruit, subtype of enum, , objects of type called apple, orange , kiwi, converted numbers calling int(apple) etc. done generating julia code so, inside macro.
in principle, could, yourself, work macro does, macro there make our life easier!
Comments
Post a Comment