You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
let findIndexi: (('a, int) => bool, t<'a>) => int
Returns Some(value) for the first element in the array that satisifies the given predicate function, or None if no element satisifies the predicate. The predicate function takes an array element and an index as its parameters. See [Array.find](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find) on MDN.
RES
// find index of first positive item at an odd index
let positiveOddElement = (item, index) => mod(index, 2) == 1 && item > 0
Js.Array.findIndexi(positiveOddElement, [66, -33, 55, 88, 22]) == 3
Js.Array.findIndexi(positiveOddElement, [66, -33, 55, -88, 22]) == -1
If it returns an int, then it does not return Some | None. Or the signature is wrong or the description is wrong.
The text was updated successfully, but these errors were encountered:
Actually it would be really useful to have a variant of these findIndex/i functions that does indeed return an option, similarly to find, if we are encouraged to use pattern matching instead of the ternary operator.
https://rescript-lang.org/docs/manual/latest/api/js/array#findindexi
If it returns an int, then it does not return Some | None. Or the signature is wrong or the description is wrong.
The text was updated successfully, but these errors were encountered: