How it comes that I instantiate an abstract class?
abstract class A {
val a: Int
}
val a = new A {val a = 3}
Or is some concrete class implicitly created? And what do those braces after new A mean?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
With this, you implicitly extend
A. What you did is syntactic sugar, equivalent to this:These brackets merely let you extend a class on the fly, creating a new, anonymous class, which instantiates the value
aand is therefore not abstract any more.