Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upExtend array_position function with instance number #13861
Comments
|
I wonder if offset is better than instance - especially when going backwards. But I see we already have strpos and strrpos with instance as a param so I'm not sure if we want a different style for arrays. |
|
BTW, this is more about function signature than syntax? |
|
|
Only concern is the negative instance. strrpos did not have that problem. May be we do array_reverse_position instead and be consistent with the strrpos? |
Or array_rposition? |
|
I'd love to take a shot at implementing this. |
You mean that negative instance doesn't make sense? Between |
|
@achao Are you still planning to work on this? Any updates? |
|
@rongrong yup! Struggling a bit ATM to build the project (following the steps here).
Any ideas?
|
|
I use java 1.8. Try |
|
@rongrong thanks! That does the trick. |
Currently
array_positiononly returns the first occurrence of the given element. We want to extendarray_positionto take an additional parameterinstancesimilar tostrpos.For example, for array
x: [1, 3, 2, 1, 4, 3, 2, 5, 4, 1]: