Question

Which implicits are present by default in Scala?

I know of RichString, Regex and some others I use.

  • But is there a list of them all?
  • Where are they implemented ? SourceFiles?
  • Is there a way to get a list of all possible implicit conversions for the current state of imports ?
Was it helpful?

Solution

The automatically imported members are:

  • The members of the java.lang package
  • The members of the scala package
  • The members of the Predef object

See The scala specification §9.1

Given that only objects (and package objects) can contain methods or values, the only place where standard (with no additional import) implicit values can be found is in Predef (the scala package does not seem to have a corresponding package object at the moment).

OTHER TIPS

I believe all scala default imports are located in scala.Predef, including implicits.

Everything declared in Predef is imported automatically including implicits. Check Predef at http://www.scala-lang.org/api/2.10.3/index.html#scala.Predef. There you can see a list of value members. You should look for items starting with implicit def.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top