Description
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:
For code examples that are idiomatic in both Scala 2 and Scala 3, we show a single tab labelled “Scala 2 and 3”:
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:
- Tour of Scala (source files are in the
_tour/
directory)-
BasicsCompare Scala 2 vs Scala 3 with tabs in Tour of Scala / Basics #2458 -
Unified TypesTranslate tour/unified-types to Scala 3 #2492 -
ClassesEnable tabbed Scala 2/3 code in tour/classes. #2474 -
Default Parameter ValuesTranslate tour/default-parameter-values to Scala 3 #2493 -
Named ArgumentsAdd tabs tour named args #2521 -
TraitsTabs for Scala 2/3 in some pages #2455 -
TuplesEnable tabbed Scala 2/3 code in tour/tuples. #2476 -
Class Composition with MixinsAdd code tabs for _tour/mixin-class-composition #2524 -
Higher-order FunctionsAdd code tabs for _tour/higher-order-functions #2525 -
Nested MethodsAdd code tabs for _tour/nested-functions #2528 -
Multiple Parameter Lists (Currying)Add code tabs for _tour/multiple-parameter-lists.md #2530 -
Case ClassesAdd code tabs for _tour/case-classes #2533 -
Pattern MatchingAdd code tabs for _tour/pattern-matching and scala3-book/control-structures #2461 -
Singleton ObjectsUpdate singleton-objects.md to use scala 2/3 tabs #2497 -
Regular Expression PatternsAdd code tabs for _tour/regular-expression-patterns #2534 -
Extractor ObjectsAdd code tabs for _tour/extractor-objects #2535 -
For ComprehensionsFor-comprehensions article updated with tabs #2494 -
Generic ClassesAdd code tabs for _tour/ generic-classes #2537 -
VariancesAdd code tabs for _tour/variances #2547 -
Upper Type BoundsAdd code tabs for _tour/upper-type-bounds #2548 -
Lower Type BoundsAdd code tabs for _tour/lower-type-bounds #2549 -
Inner ClassesAdd code tabs for _tour/inner-classes #2550 -
Abstract Type MembersAdd code tabs for _tour/abstract-types #2551 -
Compound TypesAdd code tabs for _tour/compound-types #2552 -
Self-typeAdd code tabs for _tour/self-types #2553 -
Implicit ParametersTabbed code snippets for the implicit params tour page. #2496 -
Implicit Conversionsupdate tour/implicit-conversions for Scala 3 #2630 -
Polymorphic MethodsAdd code tabs for _tour/polymorphic-methods #2554 -
Type InferenceAdd code tabs for _tour/type-inference #2557 -
OperatorsAdd code tabs for _tour/operators #2561 -
By-name ParametersAdd code tabs for _tour/by-name-parameters #2564 -
AnnotationsAdd code tabs for _tour/annotations #2566 -
Packages and ImportsAdd code tabs for _tour/packages-and-imports #2570 -
Package ObjectsTalk about top-level-definitions in the tour of Scala #2579
-
- Guides and Overviews (source files are in the
_overviews/
directory)- Scala Collections
-
IntroductionAdd code tabs for collections-2.13/introduction, overview and trait-iterable #2571 -
Mutable and Immutable CollectionsAdd code tabs for collections-2.13/introduction, overview and trait-iterable #2571 -
Trait IterableAdd code tabs for collections-2.13/introduction, overview and trait-iterable #2571 -
The sequence traits Seq, IndexedSeq, and LinearSeqAdd code tabs for collections-2.13/introduction, overview and trait-iterable #2571 -
SetsAdd code tabs for collections-2.13/sets, immutabes and muttabes #2572 -
MapsTabs for Scala 2/3 in some pages #2455 -
Concrete Immutable Collection ClassesAdd code tabs for collections-2.13/sets, immutabes and muttabes #2572 -
Concrete Mutable Collection ClassesAdd code tabs for collections-2.13/sets, immutabes and muttabes #2572 -
ArraysAdd code tabs for collections-2.13/arrays, strings, equality and views #2574 -
StringsAdd code tabs for collections-2.13/arrays, strings, equality and views #2574 -
Performance Characteristics(no code examples) -
EqualityAdd code tabs for collections-2.13/arrays, strings, equality and views #2574 -
ViewsAdd code tabs for collections-2.13/arrays, strings, equality and views #2574 -
IteratorsAdd code tabs for collections-2.13/iterators, creating..., conversions... and options #2575 -
Creating Collections From ScratchAdd code tabs for collections-2.13/iterators, creating..., conversions... and options #2575 -
Conversions Between Java and Scala CollectionsAdd code tabs for collections-2.13/iterators, creating..., conversions... and options #2575
-
-
The Architecture of Scala CollectionsAdd code tabs for overviews/architecture_collections-2.13 #2576 (review) -
Implementing Custom CollectionsAdd code tabs for overviews/custom-collections #2585 -
Adding Custom Collection OperationsCustom operations #2589 - Migration from Scala 2 to Scala 3
-
Migration TutorialAdd code tabs to the Scala 3 migration tutorial #2597 -
Scala 3 Syntax RewritingAdd code tabs to the Scala 3 syntax rewriting #2643 - Incompatibility Table
-
Syntactic ChangesAdd code tabs to Syntactic Changes #2722 -
Dropped FeaturesAdd code tabs to the Scala 3 Dropped Features #2723 -
Contextual AbstractionsAdd code tabs to contextual abstractions page #2724 -
Other Changed FeaturesAdd code tabs to Other changes page #2725 -
Type CheckerAdd code tabs to type checker page #2726 - Type Inference
-
- Compiler Plugins
- Kind Projector Migration
-
-
Scala 3 Macros(marked as scala 3 only) -
Value Classes and Universal Traitsmark value classes as scala 2 only #2863 -
An Overview of TASTyAdd more guidelines for labelling code examples for Scala 2/3 #2768 -
String InterpolationTabs for Scala 2/3 in some pages #2455 -
Implicit ClassesAdd code tabs to Contextual Abstractions #2787 -
Library Author Guideport library authors guide to Scala 3 #2873 -
Futures and PromisesPort futures article to use Scala 3 tabs #2467 -
Optimizer(marked as scala 2 only)
- Scala Collections
- Scala 3 Book (source files are in the
_overviews/scala3-book
directory)-
Scala 3 FeaturesAdd Scala 2 tabs in scala-3-book/scala-features #2495 -
Why Scala 3?Why scala 3 tabs code #2510 - A Taste of Scala
-
Hello, World!Add Scala version picker to Scala Book Hello World Page, remember preference #2450 -
The REPLAdd code tabs for scala3-book/taste-repl #2487 -
Variables and Data Typesadd scala 2&3 tables arround code in num 7 #2568 -
Control Structuresadd code tabs in num8 #2580 -
Domain Modelingadd code tabs in num9 #2581 -
Methodsadd code tabs in num10. #2582 -
First-Class Functionsadd code tabs in num11. #2583 -
Singleton Objectsadd code tabs in num12. #2584 -
Collectionsadd code tabs in num13. #2586 -
Contextual Abstractionsadd code tabs in num14. #2587 -
Top-level Definitionsadd code tabs in num15. #2588
-
-
A First Look at TypesA first look at types tabs code #2511 -
Control StructuresAdd code tabs for _tour/pattern-matching and scala3-book/control-structures #2461 -
Domain Modeling(no code)-
Toolsadd code tabs in num20. #2590 -
OOP Modelingadd code tabs in num21. #2591 -
FP Modelingadd code tabs in num22. #2592
-
-
Methods(no code)-
Method Featuresadd code tabs in num24. #2594 -
main Methodsadd code tabs. #2609
-
- Functions (no code)
-
Anonymous FunctionsAdd Scala 2 code tabs in scala3/book/fun-anonymous-functions #2602 -
Function VariablesAdd code tabs in fun-function-variables.md #2623 -
Eta Expansionadd code tabs to num30 #2644 -
Higher-Order Functionsadd code tabs to scala3 book fun-hofs #2598 -
Write Your Own map MethodAdd code tabs in scala3/book/fun-write-map-function #2625 -
Creating a Method That Returns a FunctionAdd code tabs to fun-write-method-returns-function #2664
-
-
Packaging and Importsadd code tab in packaging-imports.md #2745 -
Scala CollectionsAdd snippet tabs for collections in scala3book #2614-
Collections TypesAdd snippet tabs for collections in scala3book #2614 -
Collections MethodsAdd snippet tabs for collections in scala3book #2614
-
-
Functional ProgrammingAdd snippet tabs for functional programming in scala3book #2617-
What is Functional Programming(no code) -
Immutable ValuesAdd snippet tabs for functional programming in scala3book #2617 -
Pure FunctionsAdd snippet tabs for functional programming in scala3book #2617 -
Functions Are ValuesAdd snippet tabs for functional programming in scala3book #2617 -
Functional Error HandlingAdd snippet tabs for functional programming in scala3book #2617
-
-
Types and the Type SystemAdd code tabs for _overviews/scala3-book/types-{introduction,generics}.md #2599-
Inferred TypesAdd code tabs for _overviews/scala3-book/types-{introduction,generics}.md #2599 -
GenericsAdd code tabs for _overviews/scala3-book/types-{introduction,generics}.md #2599 -
Intersection TypesAdd code tabs for _overviews/scala3-book/types-intersection.md #2653 -
Union TypesAdd more guidelines for labelling code examples for Scala 2/3 #2768 -
Algebraic Data TypesAdd more guidelines for labelling code examples for Scala 2/3 #2768 -
Varianceadd code tab in types-variance.md #2756 -
Opaque Typesmark value classes as scala 2 only #2863 -
Structural Typesmark structural types as Scala 3 only #2864 -
Dependent Function Typesmark dependent function types as Scala 3 only #2865 -
Other Typesmark dependent function types as Scala 3 only #2865
-
-
Contextual Abstractions-
Given Instances and Using Clausesadd code tabs in _overviews/scala3-book/num59 #2640 -
Type ClassesAdd code tabs to Contextual Abstractions #2787 -
Context BoundsUpdated pages to be “Scala 3 Only” #2689 -
Given ImportsUpdated pages to be “Scala 3 Only” #2689 -
Extension MethodsAdd code tabs to Contextual Abstractions #2787 -
Multiversal EqualityUpdated pages to be “Scala 3 Only” #2689 -
Implicit ConversionsAdd code tabs to Contextual Abstractions #2787
-
- Concurrency
- Scala Tools
- Building and Testing Scala Projects with sbt
- Worksheets
-
Interacting with Javaport java interaction to scala 2 #2867 - Scala for Java Developers
- Scala for JavaScript Developers
- Scala for Python Developers
-
- Tutorials (source files are in the
_overviews/tutorials
directory or_getting-started/
)-
Getting started with Scala and sbt on the command linefeature: Add Scala 3 section for getting started with sbt #2475 -
Getting started with Scala in IntelliJAdd Scala 2 / Scala 3 syntax to the Getting Started with Intellij tutorial #2454 -
Scala for Java ProgrammersAdd scala 3 code demos for Scala for Java Programmers #2499 - Scala on Android
- Scala with Maven
-
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.