2
/** A marker indicating that a `java.lang.Runnable` provided to `scala.concurrent.ExecutionContext`
* wraps a callback provided to `Future.onComplete`.
* All callbacks provided to a `Future` end up going through `onComplete`, so this allows an
* `ExecutionContext` to special-case callbacks that were executed by `Future` if desired.
*/
trait OnCompleteRunnable {
self: Runnable =>
}
當我在scala中查看Future的源代碼時,我無法理解爲什麼self:Runnable =>上面編譯。 我知道符號=>可以在方法參數中用作按名稱調用,也可以用它來定義函數。上面的代碼看起來像是定義了一個函數,但它讓我感到困惑。scala編譯的原因是什麼(self:Runnable =>)?