[groovy-user] How to iterate over nested maps

894 views
Skip to first unread message

Matthias F. Brandstetter

unread,
Dec 16, 2014, 8:21:09 PM12/16/14
to us...@groovy.codehaus.org
In a statically compiled piece of code I have a map object that contains other maps as values. Now I want to iterate over all inner map values like this:
       compStores.each { c, m ->
println("$c -> $m")
m.each { e, l ->
println("$e -> $l")
}
}
But that doesn't work, I get the following exception:

No signature of method: ecs.EntityManager$_getAllEntityComponents_closure2_closure3.doCall() is applicable for argument types: (java.util.LinkedHashMap$Entry) values: [7b68d62d-b2fb-4d35-b74d-3065b354dde3=[test_ecs.EntityManagerTest$MockComponent1:a331423a-3325-4db2-ab98-10e272f222ea]]
Possible solutions: doCall(java.lang.Object, java.lang.Object), findAll(), findAll(), isCase(java.lang.Object), isCase(java.lang.Object)
groovy.lang.MissingMethodException: No signature of method: ecs.EntityManager$_getAllEntityComponents_closure2_closure3.doCall() is applicable for argument types: (java.util.LinkedHashMap$Entry) values: [7b68d62d-b2fb-4d35-b74d-3065b354dde3=[test_ecs.EntityManagerTest$MockComponent1:a331423a-3325-4db2-ab98-10e272f222ea]]
Possible solutions: doCall(java.lang.Object, java.lang.Object), findAll(), findAll(), isCase(java.lang.Object), isCase(java.lang.Object)
    at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:270)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1016)
    at groovy.lang.Closure.call(Closure.java:423)
    at groovy.lang.Closure.call(Closure.java:439)

Any ideas?


--
Matthias F. Brandstetter
hai...@gmail.com

Matthias F. Brandstetter

unread,
Dec 16, 2014, 8:45:18 PM12/16/14
to us...@groovy.codehaus.org
Ok sorry, I guess that was my mistake.
I fixed this by adding types to the Map object definition.

Cheers!

Reply all
Reply to author
Forward
0 new messages