Enums
Learn about creating enums, which allow you to create variables that are constrained to a specific set of values.
<<enum Food>>
<<case Apple>>
<<case Orange>>
<<case Pear>>
<<endenum>>// Declare a new variable with the default value Food.Apple
<<declare $favouriteFood = Food.Apple>>
// You can set $favouriteFood to the 'apple', 'orange' or 'pear'
// cases, but nothing else!
<<set $favouriteFood to Food.Orange>>
// You can use enums in if statements, like any other type of value:
<<if $favouriteFood == Food.Apple>>
I love apples!
<<endif>>
// You can even skip the name of the enum if Yarn Spinner can
// figure it out from context!
<<set $favouriteFood = .Pear>>Last updated
Was this helpful?
