Skip to content
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

Scala 2 Book migration - Scala Classes #3128

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

gkepka
Copy link
Contributor

@gkepka gkepka commented Dec 12, 2024

No description provided.

{% tabs traits_7 %}
{% tab 'Scala 2 and 3' %}
```scala
val s = new MyService("ComposedService") with GreetingService with TranslationService
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Intuitively, after seeing the syntax used above, someone could expect this to be defined in Scala 3 as:

val s = MyService("ComposedService") with GreetingService, TranslationService

It seems like only the Scala 2 syntax is accepted, though.

{% tabs fun-partial-5 class=tabs-scala-version%}
{% tab 'Scala 2' %}
```scala
doubledOdds.applyOrElse(4, (i: Int) => i + 1) // 5
Copy link
Contributor Author

Choose a reason for hiding this comment

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

A small fix which I omitted last time somehow.

Comment on lines +885 to +887
### Overriding an implemented method

A class can also override a method that is defined in a trait. Here is an example:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This covers both Overriding an implemented method and Mixing in multiple traits that have behaviors parts from the Scala 2 version.

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.

1 participant