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
I'm quite surprised that there currently is no array.contains(item) method. Of course, I could use a query expression or array.indexOf(item) !is () or array.some(a => a == item) but I think it would be convenient to have this simple method.
Another idea is to use a similar syntax to Python (e.g. item in array) since in is already a keyword.
Describe your problem(s)
No response
Describe your solution(s)
No response
Related area
-> Standard Library
Related issue(s) (optional)
No response
Suggested label(s) (optional)
No response
Suggested assignee(s) (optional)
No response
The text was updated successfully, but these errors were encountered:
I think probably we should add for consistency with lang.string and ECMAScript/JavaScript. It should have an additional argument, defaulting to zero, saying where to start looking from.
# Tests whether an array has a member equal to a value.
#
# + arr - the array in which to search
# + val - member to search for
# + startIndex - index to start the search from
# + return - `true` if there is a member of `arr` equal to `val` at an index >= `startIndex`,
# or `false` otherwise
public isolated function indexOf(AnydataType[] arr, AnydataType val, int startIndex = 0) returns int? = external;
Description
I'm quite surprised that there currently is no
array.contains(item)
method. Of course, I could use a query expression orarray.indexOf(item) !is ()
orarray.some(a => a == item)
but I think it would be convenient to have this simple method.Another idea is to use a similar syntax to Python (e.g.
item in array
) sincein
is already a keyword.Describe your problem(s)
No response
Describe your solution(s)
No response
Related area
-> Standard Library
Related issue(s) (optional)
No response
Suggested label(s) (optional)
No response
Suggested assignee(s) (optional)
No response
The text was updated successfully, but these errors were encountered: