notes src destructuring.md
614 B · 10 lines
Markdown
at main

Destructuring #

Destructuring is a @[programming language][] feature that allows extracting fields from structured data using similar syntax as was used to construct that structure. This is similar to @[multiple variable assignment][], but in the context of structured data.

@[Pattern matching][] is similar to destructuring, but with more flexibility. Where pattern matching allows patterns to be checked against, destructuring only allows extracting fields to values, and will not be able to check conditions at the same time. When the data cannot be destructured as requested, the program will terminate.