Browse - Programming Tips - How do I iterate through all keys/values of a HashMap in Scala?

Date: 2013may27
Language: Scala
Keywords: enumerate

Q.  How do I iterate through all keys/values of a HashMap in Scala?

A.  Use asScalaSet() like this:

import collection.JavaConversions._ val h = getJavaHashMapFromSomeWhere() for (e <- asScalaSet(h.entrySet())) { System.out.println(e.getKey() + " = " + e.getValue()) }