julialangHow to use enums in JuliaLang?
Enums are a type of data structure in JuliaLang that allow you to store a set of related values. They are useful for representing a set of related constants, such as the days of the week.
Example code
julia> @enum FRUIT apple=1 orange=2 kiwi=3
julia> FRUIT[apple]
apple::FRUIT = 1
The code above creates an enum called FRUIT
with three values.
Code explanation
@enum FRUIT
- creates an enum calledFRUIT
apple=1 orange=2 kiwi=3
- defines the values of the enumFRUIT[apple]
- prints out the valueapple
from the enum
Helpful links
More of Julialang
- How to test code in JuliaLang?
- How to round numbers in JuliaLang?
- How to get JuliaLang version?
- How to use tuples in JuliaLang?
- How to use the JuliaLang package manager?
- How to install JuliaLang?
- How to solve differential equations in JuliaLang?
- How to use try catch in JuliaLang?
- How to use regular expressions in JuliaLang?
- How to calculate the mean in JuliaLang?
See more codes...