Discord
Login
Community
DARK THEME

Exist Enums or something like?

Title says everything, i want some code like enums:

State = {A:0, B:1, C2} CurrentState = State.A

microlanguage suport it???

ok, i found lists in documentation will use that instead.

Since MicroScript is a high-level language, there are no enums. However, you can use an object:

Sign = object
  NEGATIVE = -1
  ZERO = 0
  POSITIVE = 1
end

sign = function(x)
  if x < 0 then
    return Sign.NEGATIVE
  elsif x == 0 then
    return Sign.ZERO
  end
  return Sign.POSITIVE
end

Post a reply

Progress

Status

Preview
Cancel
Post
Validate your e-mail address to participate in the community