scala - Extending new instance of a class -
hi trying understand code below scala. have class b, , has dependency class b. class c extends a. when extending class code below newing b. significant of doing this? in java can't this.
class b {} class a( b:b ) {} class c extends a( new b) {}
what b?
class b {} this empty class. in java, write same.
what a?
class a(b: b) {} this class 1 field. constructor of class takes 1 argument. constructor sets field argument. in java, write follows:
class { b b a(b b) { this.b = b } } what c?
class c extends a(new b) {} this subclass of sets field b new b. in java, write follows:
class c extends { c() { super(new b()) } }
Comments
Post a Comment