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

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -