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

Object Destructuring

Grab it from within

Destructuring allows you to access a field of a struct literal, enum expression. This is done using the val keword as follows:

struct Person(name: String, age: Int)

fun create_greet_message(person: Person): String => {
    val (name, age) = person (* extract the fields *)
    "Hello " + name + " you are " + age + " years old"
}
PreviousEnum SpecializationNextModules

Last updated 9 months ago