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

If I have a collection c of type T and there is a property p on T (of type P, say), what is the best way to do a map-by-extracting-key? val c: Collection[T] val m: Map[P, T] One way is the follow...