我正在尝试使用类似groovy中的python枚举()方法。
例如:
list = ['book','pencil','laptop','coffee']
for product, line in enumerate(list, 1):
print "Product %s in the %sth line" % (product, line)产出应是:
第1行产品手册
第2行产品铅笔
第3行的产品笔记本电脑
第4行生产咖啡
是否有办法在groovy中执行枚举方法?
致以问候!
发布于 2014-04-16 22:36:47
['book','pencil','laptop','coffee'].eachWithIndex { name, i ->
println "Product ${name} in the ${i+1} line"
}https://stackoverflow.com/questions/23121045
复制相似问题