Small ML Language
  • Small ML language
  • Installation
  • Hello World
  • Basics
    • Literals
    • Types
    • Type casting
    • Variables
    • Operators
    • Functions
    • Function chaining
    • Conditionals
    • Match
    • Arrays
    • Structs
    • Structure field Access
    • Enums
    • Enum Specialization
    • Object Destructuring
    • Modules
  • Compiler internals
    • SMLL to JAVA
Powered by GitBook
On this page
  1. Basics

Enums

Enumerating the enumarators

Enums help us to describe data that shares a common interface or type but can have different impementations and meaning. They can also be represent data-less types.

enum DaysOfTheWeek = Monday 
    | Tuesday 
    | Wednesday 
    | Thursday 
    | Friday(activit: String) 
    | Saturday
    | Sunday

This is a enum declaration that represent the days of the week as data-less types, only friday can store data.

Enum literals

val monday = DaysOfTheWeek.Monday
val friday = DaysOfTheWeek.Friday("Rest")

PreviousStructure field AccessNextEnum Specialization

Last updated 10 months ago