I want to find positions of all elements of array with specific value. Example:
def numbers = [1, 2, 3, 4, 5, 6, 5, 4, 6, 4, 9, 2];
I want to find positions of 4
, here position numbers are 3,7,9
How to find it elegant with nice groovy collections methods?
I have found the solution:
println numbers.findIndexValues {
it == 4;
}
Groovy is amazing!!!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With