Skip to content

Commit 01be9a0

Browse files
committed
fix docstrings examples - part 3
1 parent 9a3cf5e commit 01be9a0

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/Core__Array.resi

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ let make: (~length: int, 'a) => array<'a>
3636
Creates an array of length `length` initialized with the value returned from `f ` for each index.
3737
3838
```res example
39-
Array.make(~length=3, i => i + 3) == [3, 4, 5]
39+
Array.fromInitializer(~length=3, i => i + 3) == [3, 4, 5]
4040
```
4141
*/
4242
let fromInitializer: (~length: int, int => 'a) => array<'a>
@@ -622,8 +622,11 @@ type languages = ReScript | TypeScript | JavaScript
622622
623623
let array = [ReScript, JavaScript]
624624
625-
Console.log(array->Array.findIndexWithIndex((item, index) => index === 0 && item == ReScript)) // 0
626-
Console.log(array->Array.findIndex((item, index) => index === 0 && item == TypeScript)) // -1
625+
let isReScriptFirst = array->Array.findIndexWithIndex((item, index) => index === 0 && item == ReScript)
626+
let isTypeScriptFirst = array->Array.findIndexWithIndex((item, index) => index === 0 && item == TypeScript)
627+
628+
Console.log(isReScriptFirst) // 0
629+
Console.log(isTypeScriptFirst) // -1
627630
```
628631
*/
629632
@send
@@ -739,7 +742,7 @@ let reduceRight: (array<'a>, 'b, ('b, 'a) => 'b) => 'b
739742
Like `reduceRight`, but with an additional index argument on the callback function.
740743
741744
```res example
742-
Array.reduceRightWithIndex([1, 2, 3, 4], 0, (acc, x, i) => acc + x + i, 0) == 16
745+
Array.reduceRightWithIndex([1, 2, 3, 4], 0, (acc, x, i) => acc + x + i) == 16
743746
```
744747
*/
745748
let reduceRightWithIndex: (array<'a>, 'b, ('b, 'a, int) => 'b) => 'b
@@ -818,6 +821,7 @@ Use `Array.getUnsafe` only when you are sure the `index` exists (i.e. when using
818821
819822
## Examples
820823
```rescript
824+
let array = [1, 2, 3]
821825
for index in 0 to array->Array.length - 1 {
822826
let value = array->Array.getUnsafe(index)
823827
Console.log(value)
@@ -971,7 +975,7 @@ external flatMap: (array<'a>, 'a => array<'b>) => array<'b> = "flatMap"
971975
Otherwise returns `None`
972976
973977
```res example
974-
Array.findMap([1, 2, 3], n => mod(n, 2) ? Some(n - 2) : None) == 0
978+
Array.findMap([1, 2, 3], n => mod(n, 2) == 0 ? Some(n - 2) : None) == Some(0) // true
975979
```
976980
*/
977981
let findMap: (array<'a>, 'a => option<'b>) => option<'b>

0 commit comments

Comments
 (0)