0

I'm trying to find the existence of a variable number of arguments in a groovy map. I'm using map.containsKey() and it doesnt seem to be doing a string compare on the key. Here's the code:

println arg_map.keySet()
j = 1
def var = "ARG${j}"
println 'ARG1' == "ARG${j}"
println arg_map.containsKey("ARG1")
println arg_map.containsKey(var)

Heres the output:

[action, target, ARG1, ARG2]
true
true
false

How could the first two be true and the last one be false? Does containsKey() not interpret variables?

tim_yates
  • 167,322
  • 27
  • 342
  • 338
bbyrd
  • 41
  • 4

0 Answers0