Iterate over Map<Map<String,String>, Map<String,String>> in groovy
dictionary, groovy, loops
Solution
You could just use `each`:
def a = [ ([a:'tim',b:'xelian']):[ a:1,b:2 ],
([a:'alice',b:'zoe']):[ a:3,b:4 ] ]
a.each { key, value ->
println "Key $key == Value $value"
}
Problem
Hi I have complex structure ``` Map<Map<String,String>, Map<String,String>> a ``` And I want to iterate throught all its elements. I tried: ``` for(Map.Entry<Map<String,String>, Map<String,String>> first:firstMap.keySet()) { ... } ``` And the error is ``` Cannot cast object '{key1=value1, key2=value2, key3=value3, key4=value4}' with class 'java.util.LinkedHashMap' to class 'java.util.Map$Entry' due to: groovy.lang.GroovyRuntimeException: Could not find matching constructor for: java.util.Map$Entry(java.util.LinkedHashMap) ``` How to iterate over my map?