Skip to content

Commit 5d48088

Browse files
authored
Document array spreads (rescript-lang#810)
* document array spreads available in v11.1 * variable names * up version
1 parent a569345 commit 5d48088

File tree

3 files changed

+56
-8
lines changed

3 files changed

+56
-8
lines changed

compilers/package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

compilers/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"rescript-1000": "npm:[email protected]",
1111
"rescript-1010": "npm:[email protected]",
1212
"rescript-1100": "npm:[email protected]",
13-
"rescript-1110": "npm:[email protected].1",
13+
"rescript-1110": "npm:[email protected].2",
1414
"rescript-820": "npm:[email protected]",
1515
"rescript-902": "npm:[email protected]",
1616
"rescript-912": "npm:[email protected]"

pages/docs/manual/latest/array-and-list.mdx

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,54 @@ var pushedValue = myArray.push("bye");
5050

5151
</CodeTab>
5252

53+
### Array spreads
54+
55+
**Since 11.1**
56+
57+
58+
You can spread arrays of the the same type into new arrays, just like in JavaScript:
59+
60+
<CodeTab labels={["ReScript", "JS Output"]}>
61+
62+
```res example
63+
let y = [1, 2]
64+
let x = [4, 5, ...y]
65+
let x2 = [4, 5, ...y, 7, ...y]
66+
let x3 = [...y]
67+
```
68+
69+
```javascript
70+
var Belt_Array = require("rescript/lib/js/belt_Array.js");
71+
72+
var y = [
73+
1,
74+
2
75+
];
76+
77+
var x = Belt_Array.concatMany([
78+
[
79+
4,
80+
5
81+
],
82+
y
83+
]);
84+
85+
var x2 = Belt_Array.concatMany([
86+
[
87+
4,
88+
5
89+
],
90+
y,
91+
[7],
92+
y
93+
]);
94+
95+
var x3 = Belt_Array.concatMany([y]);
96+
```
97+
</CodeTab>
98+
99+
> Note that array spreads compiles to `Belt.Array.concatMany` right now. This is likely to change to native ES6 array spreads in the future.
100+
53101
## List
54102

55103
ReScript provides a singly linked list too. Lists are:

0 commit comments

Comments
 (0)