5
我想查找具有特定值的数组的所有元素的位置。 例子:查找Groovy列表中元素的所有索引
def numbers = [1, 2, 3, 4, 5, 6, 5, 4, 6, 4, 9, 2];
我想找到的4
位置,在此位置数是3,7,9
如何找到它优雅漂亮时髦的集合的方法呢?
我想查找具有特定值的数组的所有元素的位置。 例子:查找Groovy列表中元素的所有索引
def numbers = [1, 2, 3, 4, 5, 6, 5, 4, 6, 4, 9, 2];
我想找到的4
位置,在此位置数是3,7,9
如何找到它优雅漂亮时髦的集合的方法呢?
我已经找到了解决办法:
println numbers.findIndexValues {
it == 4;
}
Groovy是惊人的!