Skip to content

Update code examples to show both Scala 2 and Scala 3 syntax #2481

Open
@julienrf

Description

@julienrf

We would like to have a single website documenting both Scala 2 and Scala 3 since, in most of the cases, their syntax is very similar, and their features are almost all the same. However, there can still be some syntactic differences between idiomatic Scala 2 code and idiomatic Scala 3 code. Therefore, we want to display both styles in our code examples by using tabs:

Screenshot 2022-07-27 at 14-37-55 Futures and Promises

For code examples that are idiomatic in both Scala 2 and Scala 3, we show a single tab labelled “Scala 2 and 3”:

Screenshot from 2022-07-27 14-39-09


Unfortunately, there are lots of code examples in the documentation, and updating all of them is a huge (and repetitive) task for one person. But if a few dozen members of the community were each updating a couple of pages, the job would be done very quickly. So, everyone is welcome to help!

The policy for updating code examples is the following: show the most idiomatic style for all the code examples, for Scala 2 and Scala 3. For Scala 3 code examples, this means using the new control syntax, the indentation-significant syntax, using and given, @main, .* wildcard import, ? wildcard type argument, tuple indexed access, etc.

You can find the instructions to write tabbed code examples in the documentation.

Here is the list of pages that need to be updated. If you are interested in contributing, please add a comment to announce that you start working on a page, and I will mark it “in progress” to prevent overlapping contributions:


Note: in some cases, not only the code examples need to be updated, but also the text in the documentation (e.g. @main methods, extension methods, contextual abstractions, enums). In that case, the task is more complicated. Feel free to ask for help on the #scala-contributors channel of the Scala discord server, or consider switching to a simpler page.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions