Reputation: 4743
I'm looking into the scala actors library, and there I found the following code:
private[scheduler] trait TerminationMonitor {
_: IScheduler =>
protected var activeActors = 0
...
The question is what is the meaning of _: IScheduler => is here?
I'm new to Scala and it confuses me that there are so many different meanings with the underscore.
Thanks for your help in advance!
Upvotes: 3
Views: 233
Reputation: 67828
This usage of the underscore is similar to those:
someElem match {
case _: String => doSomething()
}
val k = (_: Int) => "This does not use the Int argument."
val (m, _, o) = (1,2,3)
It is a syntactic placeholder for an identifier (variable) which is immediately discarded afterwards.
In your example, the naming of the self-type is therefore being avoided. (But since the self-type reference is always accessible as this
, it would be equivalent to writing this: IScheduler =>
in that special case.)
Upvotes: 5