@@ -36,7 +36,7 @@ let make: (~length: int, 'a) => array<'a>
36
36
Creates an array of length `length` initialized with the value returned from `f ` for each index.
37
37
38
38
```res example
39
- Array.make (~length=3, i => i + 3) == [3, 4, 5]
39
+ Array.fromInitializer (~length=3, i => i + 3) == [3, 4, 5]
40
40
```
41
41
*/
42
42
let fromInitializer : (~length : int , int => 'a ) => array <'a >
@@ -622,8 +622,11 @@ type languages = ReScript | TypeScript | JavaScript
622
622
623
623
let array = [ReScript, JavaScript]
624
624
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
627
630
```
628
631
*/
629
632
@send
@@ -739,7 +742,7 @@ let reduceRight: (array<'a>, 'b, ('b, 'a) => 'b) => 'b
739
742
Like `reduceRight`, but with an additional index argument on the callback function.
740
743
741
744
```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
743
746
```
744
747
*/
745
748
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
818
821
819
822
## Examples
820
823
```rescript
824
+ let array = [1, 2, 3]
821
825
for index in 0 to array->Array.length - 1 {
822
826
let value = array->Array.getUnsafe(index)
823
827
Console.log(value)
@@ -971,7 +975,7 @@ external flatMap: (array<'a>, 'a => array<'b>) => array<'b> = "flatMap"
971
975
Otherwise returns `None`
972
976
973
977
```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
975
979
```
976
980
*/
977
981
let findMap : (array <'a >, 'a => option <'b >) => option <'b >
0 commit comments