Expanding on Kevin's answer and explaining why it's not possibly for scaladoc to tell you what implicit conversion exists: implicit conversions only come into play when your code would not compile otherwise.
You can see it as an error recovery mechanism for type errors that is activated during compilation. In this case, Array[String]
does not have a mkString
method. This code would not compile, because that method does not exists on Array[T]
. But before giving up the compiler will look for an implicit conversion in scope.
It happens that Predef
brings a number of implicit conversions in scope and one that will apply here.
Finding out which implicit conversion applies can be done by compiling with the -Xprint:typer
flag. In this case it would print:
$ scalac -d classes -Xprint:typer A.scala
[[syntax trees at end of typer]]// Scala source: A.scala
package <empty> {
final object myApp extends java.lang.Object with App with ScalaObject {
def this(): object myApp = {
myApp.super.this();
()
};
scala.this.Predef.println("Echo ".+(scala.this.Predef.refArrayOps[String](myApp.this.args).mkString(" ")))
}
}
So you can see that Predef.refArrayOps
is in fact the implicit conversion used. It converts your array into a ArrayOps[String]
which does have a mkString
method.
So with that in mind you can see why scaladoc for Array
cannot tell you what implicit conversion could apply. It could be anything. It is in fact wholly based on the fact that there is no such method. Only the compiler will know what implicit it found based on the code.
You can even define your own implicit conversion:
object myApp extends App {
implicit def myImplicit(arr:Array[String]) = new {
def mkString(s:String) = arr.length + s
}
println("Echo " + (args mkString(" ")))
}
Which would have the following effect:
$ scala -cp classes myApp a b c
Echo 3
Obviously scaladoc won't be able to show that. Note that the Eclipse Scala plug in can bring you to the implementation of mkString
by pressing F3 (you'll end up in TraversableOnce
).