How can I override a function of type member in Scala? -


suppose have code:

class c extends a#b {   override def fun(): int = 100 }  trait {   type b = {      def fun(): int    } } 

the compiler says:

class type required object{def fun(): int} found   class c extends a#b {                     ^ 

how can understand error?

you cannot extend structural type in scala. structural types denote bunch of methods type has define in order used @ places structural type expected.

thus, sufficient write

class c {   def fun(): int = 100 } 

to pass objects of type c variables of b.


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -