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

Match

Like matching outfits

The match expression is inspired by the case expression from Standard ML, and th e match expression from Rust. The match expression allows you to check if a value is an expected value or type and it can also be used to destructure enums and struct value. More on those later, for now lets match some values. The match expression takes a match value, followed by a list of match cases and their respective bodies to run if they match. The default case is represented by an underscore symbol.

match 1 + 1 {
    2 -> true
    _ -> false
}

PreviousConditionalsNextArrays

Last updated 10 months ago