[PUP-9482] add index function to return index/key in array/hash/string and other iterables Created: 2017/02/17 Updated: 2019/02/20 Resolved: 2019/02/14
|Fix Version/s:||PUP 6.3.0|
|Remaining Estimate:||Not Specified|
|Time Spent:||Not Specified|
|Original Estimate:||Not Specified|
|Release Notes:||New Feature|
|Release Notes Summary:||An `index()` function has been added to puppet that can return the index/key in an Array, Hash, String or other iterable value that is either equal to a given value or for which a given lambda returns a truthy value. Earlier this was difficult to do.|
|QA Risk Assessment:||Needs Assessment|
add an array_index function which returns the index of a specified element in an array,
see the solution in: https://ask.puppet.com/question/4763/how-to-get-an-array-index-in-manifest/
|Comment by Henrik Lindberg [ 2019/02/11 ]|
This question has also come up in chat and conversations. While doable, it is a bit difficult to achieve the same by using a reduce(), or by writing a function that iterates with each() and return() when a value was found. It has also been asked how to find the index to a char sequence in a string (which is even trickier).
I am taking this ticket and repurposing it for a general index() function to be added to puppet core.
|Comment by Kenn Hussey [ 2019/02/12 ]|
Henrik Lindberg are you still planning to get this in for Puppet 6.3 (in which case the PR needs to be merged by EOD today)?