Skip to content

fix: needs var for Dog extends abstract class #2453

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 5, 2022

Conversation

geminicaprograms
Copy link
Contributor

In the Dog extends abstract class (aka Scala 2 way) var keyword is missing in the class defition

class Dog(name: String, age: Int) extends Pet(name):
...

As a result the Dog class fails to compile with the following error
class Dog needs to be abstract, since def age: Int in class Pet is not defined

adding var to the definition solves to problem

class Dog(name: String, var age: Int) extends Pet(name):
...

In the _Dog extends abstract class_ (aka Scala 2 way) `var` keyword is missing in the class defition
```
class Dog(name: String, age: Int) extends Pet(name):
...
```
As a result the `Dog` class fails to compile with the following error
`class Dog needs to be abstract, since def age: Int in class Pet is not defined`

adding `var` to the definition solves to problem
```
class Dog(name: String, var age: Int) extends Pet(name):
...
```
Copy link
Contributor

@julienrf julienrf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, good catch and thank you for the fix!

@julienrf julienrf merged commit 7728d94 into scala:main Jul 5, 2022
@geminicaprograms geminicaprograms deleted the patch-1 branch July 6, 2022 05:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants