Skip to content

Enums #120

@KCreate

Description

@KCreate
enum MyEnum {
  Foo
  Bar
  Baz
}

MyEnum.Foo # => 0
MyEnum.Bar # => 1
MyEnum.Baz # => 2

Enums can also have static methods

enum MyEnum {
  Foo
  Bar
  Baz

  func is_foo(value) {
    value == @Foo
  }
}

The values of an enum are Numeric values starting at 0, incrementing with each value added to the enum. The enum is represented as an object.

The above code is equivalent to the following object literal:

let MyEnum = {
  const Foo = 0
  const Bar = 1
  const Baz = 2

  func is_foo(value) {
    value == @Foo
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions