每個和 EveryWithIndex
each 和 eachWithIndex 是迭代集合的方法。
每個都有 it(預設迭代器)和 eachWithIndex 有 it,index(預設迭代器,預設索引)。
我們還可以更改預設迭代器/索引。請看下面的例子。
def list = [1,2,5,7]
list.each{
    println it
}
list.each{val->
    println val
}
list.eachWithIndex{it,index->
    println "value " + it + " at index " +index
}