Destructuring
=============
```Example from 1 languages: JavaScript
const o = {p: 42, q: true};
const {p, q} = o;
```
```Example from 1 languages: Python
# destructuring assignment works for sequences, including nested ones:
(a, (b, c), *d) = (1, (2, 3), 4, 5, 6) # result: a=1, b=2, c=3, d=(4,5,6)
# it is NOT implemented for more complicated types like dictionaries:
{"a": a} = {"a": 1} # ERROR
# more complex destructuring is possible using the match statement:
d = {"a": {"b": [1, 2]}}
match d:
case {"a": {"b": [1, x]}}: pass # result: x=2
case _: raise ValueError("destructuring failed!")
```
```Example from 1 languages: Reason
type person = {name: string, age: int};
let somePerson = {name: "Guy", age: 30};
let {name, age} = somePerson;
```
```Example from 1 languages: Coconut
{"list": [0] + rest} = {"list": [0, 1, 2, 3]}
```
```Example from 1 languages: bog
let add = fn ((a,b)) a + b
let tuplify = fn (a,b) (a,b)
return add(tuplify(1,2)) # 3
```
*
Languages *with* Destructuring include JavaScript, Python, Reason, Coconut, bog, Bio
*
Languages *without* Destructuring include Lil
*
View all concepts with or missing a *hasDestructuring* measurement
http://pldb.info/../lists/explorer.html#columns=rank~id~appeared~tags~creators~hasDestructuring&searchBuilder=%7B%22criteria%22%3A%5B%7B%22condition%22%3A%22null%22%2C%22data%22%3A%22hasDestructuring%22%2C%22origData%22%3A%22hasDestructuring%22%2C%22type%22%3A%22num%22%2C%22value%22%3A%5B%5D%7D%5D%2C%22logic%22%3A%22AND%22%7D missing
http://pldb.info/../lists/explorer.html#columns=rank~id~appeared~tags~creators~hasDestructuring&searchBuilder=%7B%22criteria%22%3A%5B%7B%22condition%22%3A%22!null%22%2C%22data%22%3A%22hasDestructuring%22%2C%22origData%22%3A%22hasDestructuring%22%2C%22type%22%3A%22num%22%2C%22value%22%3A%5B%5D%7D%5D%2C%22logic%22%3A%22AND%22%7D with
*
Read more about Destructuring on the web: 1.
https://reasonml.github.io/docs/en/destructuring 1.
Built with Scroll v178.2.3