walk

Came across a moose eating a tree

Diary entry from January, 18, 2011, Wasilla, Alaska: While on a walk this morning I came across a large moose. It was just standing there, eating a tree. I didn‘t bother it, and it didn‘t bother me.

How to traverse a Map in Scala (for loop, foreach)

This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 11.18, “How to Traverse a Map in Scala”

Problem

You want to iterate over the elements in a map.

Solution

There are several different ways to iterate over the elements in a map. Given a sample map: