[英]Groovy map, get, variable, Jenkins
我在 Groovy 中的映射有问题。 我想获得一个基于变量的值。
def function(){
map = [
'test1': '1234',
'test2': '4567'
]
var=test1
def result = map.get.("$var")
return result
}
但不幸的是。 我总是回来:
无法在 null object 上获取属性“[test1]”
You are making a HashMap behind the scenes here and the way you are accessing it map.get.["$var"]
Groovy is trying to access a key called "get" on your variable map.
你只想要map[var]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.