Reputation: 1134
The Scala website doesn't show me how the actual distinct
function of List
works and there is no full signature of the function.
Is there a way to find the actual function signature or its definition ?
Upvotes: 0
Views: 576
Reputation: 9820
The distinct
function of List
is defined in SeqLike
.
You can find its distinct
implementation on GitHub.
// Scala 2.11.7
def distinct: Repr = {
val b = newBuilder
val seen = mutable.HashSet[A]()
for (x <- this) {
if (!seen(x)) {
b += x
seen += x
}
}
b.result()
}
Note that at the top of every ScalaDoc page (below the description), there is a link to the source file on GitHub.
Upvotes: 2