Skip to content

Destructuring

Giorgio Garofalo edited this page Apr 25, 2025 · 9 revisions

Destructuring

Destructuring is the operation that splits a lambda parameter into its bare components. For instance, a pair has two components, while a generic iterable has many.

The following types are destructurable:

A value is destructured into N components if all the following conditions are met:

  • Its type is destructurable;
  • The lambda expects a single argument (such as .foreach);
  • N > 1 lambda parameters are supplied.

When the lambda argument is destructured, the operation is performed on its components rather than the element itself.

In the following example we define a Dictionary and iterate over its destructured key-value components:

.var {mydictionary}
  .dictionary 
    - a: 1
    - b: 2
    - c: 3

.foreach {.mydictionary}
    key value: <!-- 2 lambda parameters = each pair is destructured into its 2 components -->
    **.key** has value **.value**
Destructuring

Getting started [NEW!]

Documentation

CLI tools

Markdown enhancements

Functions

Setting up

Multi-file projects

Layout

Charts & diagrams

Scripting & control flow

Utilities

Slides

I/O

Native content

Value types

Built-in libraries

  • Paper: abstract, definitions, theorems, and more

Extra features

Inside Quarkdown

Clone this wiki locally