Scala best way of turning a Collection into a Map-by-key?

You can use

c map (t => t.getP -> t) toMap

but be aware that this needs 2 traversals.

Leave a Comment