kiwi icon indicating copy to clipboard operation
kiwi copied to clipboard

Feature - Enumerations

Open fuseraft opened this issue 10 months ago • 0 comments

An enumeration can be iterated like an immutable hash.

The values it contains can only be Integer, Double, Boolean, and String.

Naming conventions are up to the developer. flags, Flags, __f_l_a_g_s__ are all acceptable names for enums (though the last one is just plain silly).

enum Flag
  none = 0
  red = 1 << 0
  green = 1 << 1
  blue = 1 << 2
end

println(Flag.blue) # 4
enum Color
  black = "rgb(0,0,0)"
  red = "rgb(255,0,0)"
  green = "rgb(0,255,0)"
  blue = "rgb(0,0,255)"
end

println(Color.black) # rgb(0,0,0)

fuseraft avatar Apr 08 '24 06:04 fuseraft