2011-06-17 37 views
1

我有一些像這樣的代碼:Scala Actor子類無法訪問mailboxSize?

package something 

import scala.actors.Actor 
import scala.actors.Actor._ 

class Foo extends Actor { 
    private val random = new Random() 

    def doWork() { 
    if (self.mailboxSize >= 3) { 
     println("Actor loaded, use another node") 
    } else { 
     doSomething() 
    } 
} 
... more code 
} 

,當我嘗試編譯它(FSC * .scala),我得到:

error: method mailboxSize in trait Reactor cannot be accessed in scala.actors.Actor 
Access to protected method mailboxSize not permitted because 
prefix type scala.actors.Actor does not conform to 
class Foo in package something where the access take place 

mailboxSize是受保護的,但我應該能夠在子類中訪問它的權利?

謝謝!

回答

5

嘗試

this.mailboxSize 

抱歉,現在不能檢查。

+0

完美。謝謝! – Alex