0
votes

I'm trying to find documentation of the Map.toList method in Scala but looking at documentation this is a trait : http://www.scala-lang.org/api/current/index.html#scala.collection.immutable.Map . So how can I find the documentation for scala Map? WHen I instatiate a Map am I just instantiating the trait ?

3

3 Answers

1
votes

Trait scala.collection.immutable.Map is a contract. It's valid for all implementations, so its documentation is a documentation for any immutable scala Map.

In current implementation method Map.apply (Map(a -> b, c -> d, ...)) creates HashMap for more than 4 elements.

There are also classes Map1 - Map4 for 1-4 elements. Also there is a singleton EmptyMap.

But this behavior could be changed in next scala versions in case there will be better implementation for general purpose.

0
votes

It is defined in Predef. Also its source might be useful.

0
votes

Traits cannot be instantiated. They are abstract by definition. If they're actually fully implemented, they can (appear to) be instantiated by creating an anonymous type at the point of instantiation:

val x = new FullyImplementedTraitName { }

As to your main question, the documentation for scala.collection.Map should tell you everything you need to know. When you have the full frameset for the ScalaDocs displayed the filter text field at the upper left allows you to narrow down the class and package list by entering a the name (or portion thereof) you're looking for.