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

html - Difficulties with background-image property -

visual studio code - What does the isShellCommand property actually do and how should you use it? -

ios - Segue not passing data between ViewControllers -