Groovy iterate over map keys
examples/groovy/iterate_over_map_keys.groovy
def data = [ name : 'Foo Bar', age : 42, email : 'zoo@bor.com', ] println(data) for (field in data.keySet()) { println(field) } my_keys = data.keySet() println(my_keys.getClass()) // class java.util.LinkedHashMap$LinkedKeySet
If instead of iterating over the keys, you'd like to create an Array from the key, there is another example to convert the LinkedKeySet to and ArrayList.
![Gabor Szabo](/img/szabgab.png)
Published on 2019-08-24
If you have any comments or questions, feel free to post them on the source of this page in GitHub. Source on GitHub.
Comment on this post