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 append to an array in JuliaLang?
- How to use the println function in JuliaLang?
- How to sort in JuliaLang?
- How to use lambda functions in JuliaLang?
- How to work with matrices in JuliaLang?
- How to install JuliaLang on Ubuntu?
- How to install JuliaLang?
- How to measure execution time in JuliaLang?
- How to use the range function in JuliaLang?
See more codes...