Reputation: 117
This a example code in the book:
abstract class Check {
def check():String = "Checked Application Details... "
}
trait EmploymentCheck extends Check{
override def check():String = "Check Employment ... " + super.check()
}
val app = new Check with EmploymentCheck
Which make me confused is the new Check
, How can we instantiation a abstract class ? And why it will work by with EmploymentCheck
?
Upvotes: 0
Views: 135
Reputation: 38207
The type you are instantiating is Check with EmploymentCheck
not Check
, and Check with EmploymentCheck
is not abstract because the abstract member check
has been filled in by EmploymentCheck
.
Upvotes: 1
Reputation:
new Check with EmploymentCheck
generates an anonymous concrete subclass of Check
. No abstract class is instantiated.
scala> app.getClass
res0: Class[_ <: EmploymentCheck] = class $anon$1
Upvotes: 4