标签: list groovy range
如何通过变量获取监听:
var start = 5 var end = 10 myList.getAt(start..end)
答案 0 :(得分:2)
你走了:
def list = [1,2,4] def a = 1 def b = 2 assert list.getAt((a)..(b)) == [2, 4] assert list[a..b] == [2, 4]