initialization - Scala: pre-initialize val while extending a class -


how pre-initialize val , extend class in scala?

e.g.:

object start {   def main(args: array[string]): unit = {         new t()         new t2()         //t3?   } }  class t extends{val z = 10} x  y class t2 extends x y {val z=10} //class t3 extends{val z = 10}  ??? z x y //????  class z  trait  x {   val z :int }  trait y { :x =>   println("test: "+z)   } 

use:

class t3 extends {val z = 10} z x y 

scala language specification 2.9, 5.1.6:

earlydefs ::= ‘{’ [earlydef {semi earlydef}] ‘}’ ‘with’ 

so definition always has followed with


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -