Index is duplicated for an array #315
abhishekrongali
started this conversation in
General
Replies: 2 comments 4 replies
-
The function gives you the array index of the first value in the array that's the same as the value you gave it. The first and third invocations of the function are the same, so of course they must give the same result. I don't know what to suggest here, as I can't tell what you're trying to do. |
Beta Was this translation helpful? Give feedback.
3 replies
-
Perhaps he wishes to have a different function. Something like
.... with negative occurence indices specify from the tail rather than from head. Just an idea. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Can you please help me with how to avoid duplicate of index when Iterating through array list ?
Example:
array -> [{"value" : "a"}, {"value" : "b"}, {"value" : "a"}]
I used index-of(array, value) then I got below index values
{"value" : "a"} -> index 0
{"value" : "b"} -> index 1
{"value" : "a"} -> index 0 // (Expecting index value should be 2)
Even values are same, it should have incremental index!
Thanks in advance
Beta Was this translation helpful? Give feedback.
All reactions