There is a Shadowed Implicit Value Members section in StringOps doc. E.g.:
def split(arg0: String, arg1: Int): Array[String]
Implicit information
This member is added by an implicit conversion from StringOps to String performed by method unaugmentString in scala.Predef.Shadowing
This implicitly inherited member is shadowed by one or more members in this class. To access this member you can use a type ascription:(stringOps: String).split(arg0, arg1)
Definition Classes
String
But when I try to run following program:
"aaa bbb ccc".split(" ", 2) //> res0: Array[String] = Array(aaa, bbb ccc)
Calling the String.split(arg0: String, arg1: Int)
doesn't need using type ascription as in the doc described.
So what is the Shadowed Implicit Value Members referring to? I tried to ask google but cannot find any reference.
Is it something like:
class A {
def foo() = println("foo")
}
class AOps(a: A) {
def bar() = println("bar")
def foo() = println("new foo")
def foo(i: Int) = println("foo %d".format(i))
}
object Program {
implicit def A2AOps(a: A) = new AOps(a) //> A2AOps: (a: A)AOps
val a = new A() //> a : A = A@15669ae
a.foo //> foo
a.bar //> bar
(a: AOps).foo //> new foo
a.foo(1) //> foo 1
}
Then the String.split(...)
and StringOps.split
function signatures are different, so there will no need be "type ascription".
Is this what "Shadowed Implicit Value Members" stands for? I'm a little puzzled. Thanks!