diff --git a/Gemfile.lock b/Gemfile.lock
index 55d8b82a72..4f956e6336 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -279,7 +279,7 @@ GEM
concurrent-ruby (~> 1.0)
unicode-display_width (1.8.0)
uri (0.13.0)
- webrick (1.9.0)
+ webrick (1.9.1)
yell (2.2.2)
zeitwerk (2.6.7)
diff --git a/_config.yml b/_config.yml
index aed90af2e1..b27d1b387d 100644
--- a/_config.yml
+++ b/_config.yml
@@ -15,9 +15,9 @@ keywords:
- Document
- Guide
-scala-version: 2.13.15
+scala-version: 2.13.16
scala-212-version: 2.12.20
-scala-3-version: 3.5.2
+scala-3-version: 3.6.3
collections:
style:
diff --git a/_data/doc-nav-header.yml b/_data/doc-nav-header.yml
index 4f2bbd82cf..772da79703 100644
--- a/_data/doc-nav-header.yml
+++ b/_data/doc-nav-header.yml
@@ -5,17 +5,6 @@
url: "/getting-started/install-scala.html"
- title: Scala IDEs
url: "/getting-started/scala-ides.html"
-- title: Scala 3
- url: "#"
- submenu:
- - title: What's New?
- url: "/scala3/new-in-scala3.html"
- - title: Migrating From Scala 2
- url: "/scala3/guides/migration/compatibility-intro.html"
- - title: New Features for Scaladoc
- url: "/scala3/scaladoc.html"
- - title: Videos and Talks
- url: "/scala3/talks.html"
- title: Learn
url: "#"
submenu:
@@ -27,8 +16,17 @@
url: "/overviews/scala-book/introduction.html"
- title: Online Courses
url: "/online-courses.html"
- - title: Online Resources
- url: "/learn.html"
+- title: Scala 3 Migration
+ url: "#"
+ submenu:
+ - title: What's New?
+ url: "/scala3/new-in-scala3.html"
+ - title: Migrating From Scala 2
+ url: "/scala3/guides/migration/compatibility-intro.html"
+ - title: New Features for Scaladoc
+ url: "/scala3/scaladoc.html"
+ - title: Videos and Talks
+ url: "/scala3/talks.html"
- title: Tutorials
url: "#"
submenu:
diff --git a/_data/footer.yml b/_data/footer.yml
index 5e24e08b6d..789017f8b9 100644
--- a/_data/footer.yml
+++ b/_data/footer.yml
@@ -57,9 +57,11 @@
- title: GitHub
url: "https://github.com/scala/scala"
- title: Mastodon
- url: https://fosstodon.org/@scala_lang
- - title: Twitter
- url: "https://twitter.com/scala_lang"
+ url: "https://fosstodon.org/@scala_lang"
+ - title: Bluesky
+ url: "https://bsky.app/profile/scala-lang.org"
+ - title: X
+ url: "https://x.com/scala_lang"
- title: Discord
url: "https://discord.com/invite/scala"
- title: LinkedIn
diff --git a/_fr/getting-started/install-scala.md b/_fr/getting-started/install-scala.md
index a94b708cb0..76f7c537f9 100644
--- a/_fr/getting-started/install-scala.md
+++ b/_fr/getting-started/install-scala.md
@@ -188,7 +188,7 @@ Une fois que vous avez terminé le tutoriel ce dessus, vous pouvez consulter :
* [The Scala Book](/scala3/book/introduction.html) ([Lien](/overviews/scala-book/introduction.html) vers la version Scala 2), qui fournit un ensemble de courtes leçons et introduit les fonctionnalités principales de Scala.
* [The Tour of Scala](/tour/tour-of-scala.html) pour une introduction des fonctionnalités Scala.
-* [Learning Resources](/learn.html), qui contient des tutoriels et des cours interactifs.
+* [Learning Courses](/online-courses.html), qui contient des tutoriels et des cours interactifs.
* [Our list of some popular Scala books](/books.html).
* [The migration guide](/scala3/guides/migration/compatibility-intro.html) pour vous aider à migrer votre code Scala 2 vers Scala 3.
diff --git a/_fr/tour/tour-of-scala.md b/_fr/tour/tour-of-scala.md
index cb9fb2fcc6..f5d0f5d20a 100644
--- a/_fr/tour/tour-of-scala.md
+++ b/_fr/tour/tour-of-scala.md
@@ -14,8 +14,8 @@ Ce tour contient une introduction morceaux par morceaux aux fonctionnalités les
utilisées en Scala. Il est adressé aux novices de Scala.
Ceci est un bref tour du language, non pas un tutoriel complet.
-Si vous recherchez un guide plus détaillé, il est préférable d'opter pour [un livre](/books.html) ou de consulter
-[d'autres ressources](/learn.html).
+Si vous recherchez un guide plus détaillé, il est préférable d'opter pour [un livre](/books.html) ou de suivre
+[un cours en ligne](/online-courses.html).
## Qu'est-ce que le Scala ?
Scala est un langage de programmation à multiples paradigmes désigné pour exprimer des motifs de programmation communs de
diff --git a/_includes/_markdown/courses-coursera.md b/_includes/_markdown/courses-coursera.md
new file mode 100644
index 0000000000..403c5e3100
--- /dev/null
+++ b/_includes/_markdown/courses-coursera.md
@@ -0,0 +1,18 @@
+## Scala Courses on Coursera by EPFL
+
+The [Scala Center](https://scala.epfl.ch) at EPFL offers free online courses of various levels, from beginner to advanced.
+
+For beginners:
+
+- [Effective Programming in Scala](https://www.coursera.org/learn/effective-scala): a practical introduction to Scala for professional developers
+- [Functional Programming Principles in Scala](https://www.coursera.org/learn/scala-functional-programming): the foundational course by Martin Odersky, Scala's creator
+
+More advanced topics:
+
+- [Functional Program Design in Scala](https://www.coursera.org/learn/scala-functional-program-design): builds on functional principles with more advanced concepts
+- [Parallel Programming](https://www.coursera.org/learn/scala-parallel-programming)
+- [Big Data Analysis with Scala and Spark](https://www.coursera.org/learn/scala-spark-big-data)
+- [Programming Reactive Systems](https://www.coursera.org/learn/scala-akka-reactive): introduces Akka, actors and reactive streams
+
+All courses are free to audit, with an option to pay for a certificate, to showcase your skills on your resume or LinkedIn.
+For more on Scala Center's online courses, visit [this page](https://docs.scala-lang.org/online-courses.html#learning-platforms).
diff --git a/_includes/_markdown/courses-extension-school.md b/_includes/_markdown/courses-extension-school.md
new file mode 100644
index 0000000000..003c42a4f2
--- /dev/null
+++ b/_includes/_markdown/courses-extension-school.md
@@ -0,0 +1,9 @@
+## EPFL Extension School: Effective Programming in Scala
+
+Subscribing to [Effective programming in Scala](https://www.epfl.ch/education/continuing-education/effective-programming-in-scala/) on the EPFL Extension School offers:
+
+- Regular Q&A sessions and code reviews with experts from the Scala team
+- An [Extension School certificate](https://www.epfl.ch/education/continuing-education/certifications/) upon completion
+
+This course combines video lessons, written content and hands-on exercise focused on practical aspects, including business domain modeling, error handling, data manipulation, and task parallelization.
+For more on Scala Center's online courses, visit [this page](https://docs.scala-lang.org/online-courses.html#learning-platforms).
diff --git a/_includes/_markdown/courses-rock-the-jvm.md b/_includes/_markdown/courses-rock-the-jvm.md
new file mode 100644
index 0000000000..5c08cefd40
--- /dev/null
+++ b/_includes/_markdown/courses-rock-the-jvm.md
@@ -0,0 +1,13 @@
+## Rock the JVM Courses
+
+[Rock the JVM](https://rockthejvm.com) is a learning platform with free and premium courses on the Scala language, and all major libraries and tools in the Scala ecosystem: Typelevel, Zio, Akka/Pekko, Spark, and others.
+Its main Scala courses are:
+
+- [Scala at Light Speed](https://rockthejvm.com/courses/scala-at-light-speed) (free)
+- [Scala & Functional Programming Essentials](https://rockthejvm.com/courses/scala-essentials) (premium)
+- [Advanced Scala and Functional Programming](https://rockthejvm.com/courses/advanced-scala) (premium)
+- [Scala Macros & Metaprogramming](https://rockthejvm.com/courses/scala-macros-and-metaprogramming) (premium)
+
+Other courses teach how to build full-stack Scala application, using [Typelevel](https://rockthejvm.com/courses/typelevel-rite-of-passage) or [ZIO](https://rockthejvm.com/courses/zio-rite-of-passage) ecosystems.
+
+Explore more premium [courses](https://rockthejvm.com/courses) or check out [free video tutorials](https://youtube.com/rockthejvm) and [articles](https://rockthejvm.com/articles).
diff --git a/_includes/_markdown/install-cask.md b/_includes/_markdown/install-cask.md
index afb2754321..0424ce4ae6 100644
--- a/_includes/_markdown/install-cask.md
+++ b/_includes/_markdown/install-cask.md
@@ -5,7 +5,7 @@
{% tab 'Scala CLI' %}
You can declare a dependency on Cask with the following `using` directive:
```scala
-//> using dep "com.lihaoyi::cask::0.9.2"
+//> using dep com.lihaoyi::cask::0.9.2
```
{% endtab %}
@@ -25,7 +25,7 @@ lazy val example = project.in(file("example"))
In your `build.sc`, you can add a dependency on Cask:
```scala
object example extends RootModule with ScalaModule {
- def scalaVersion = "3.3.3"
+ def scalaVersion = "3.3.4"
def ivyDeps = Agg(
ivy"com.lihaoyi::cask::0.9.2"
)
diff --git a/_includes/_markdown/install-munit.md b/_includes/_markdown/install-munit.md
index 853d18e230..e1ebf130c9 100644
--- a/_includes/_markdown/install-munit.md
+++ b/_includes/_markdown/install-munit.md
@@ -10,7 +10,7 @@ MUnit, being a testing framework, is only available in test files: files in a `t
Alternatively, you can require just a specific version of MUnit:
```scala
-//> using dep org.scalameta::munit:1.0.0-M7
+//> using dep org.scalameta::munit:1.0.3
```
{% endtab %}
{% tab 'sbt' %}
@@ -18,7 +18,7 @@ In your build.sbt file, you can add the dependency on toolkit-test:
```scala
lazy val example = project.in(file("."))
.settings(
- scalaVersion := "3.3.3",
+ scalaVersion := "3.3.4",
libraryDependencies += "org.scala-lang" %% "toolkit-test" % "0.1.7" % Test
)
```
@@ -27,14 +27,14 @@ Here the `Test` configuration means that the dependency is only used by the sour
Alternatively, you can require just a specific version of MUnit:
```scala
-libraryDependencies += "org.scalameta" %% "munit" % "1.0.0-M7" % Test
+libraryDependencies += "org.scalameta" %% "munit" % "1.0.3" % Test
```
{% endtab %}
{% tab 'Mill' %}
In your build.sc file, you can add a `test` object extending `Tests` and `TestModule.Munit`:
```scala
object example extends ScalaModule {
- def scalaVersion = "3.3.3"
+ def scalaVersion = "3.3.4"
object test extends Tests with TestModule.Munit {
def ivyDeps =
Agg(
@@ -46,7 +46,7 @@ object example extends ScalaModule {
Alternatively, you can require just a specific version of MUnit:
```scala
-ivy"org.scalameta::munit:1.0.0-M7"
+ivy"org.scalameta::munit:1.0.3"
```
{% endtab %}
{% endtabs %}
diff --git a/_includes/_markdown/install-os-lib.md b/_includes/_markdown/install-os-lib.md
index c35388e0a3..b62c5ce102 100644
--- a/_includes/_markdown/install-os-lib.md
+++ b/_includes/_markdown/install-os-lib.md
@@ -17,7 +17,7 @@ In your `build.sbt`, you can add a dependency on the toolkit:
```scala
lazy val example = project.in(file("."))
.settings(
- scalaVersion := "3.3.3",
+ scalaVersion := "3.3.4",
libraryDependencies += "org.scala-lang" %% "toolkit" % "0.1.7"
)
```
@@ -30,7 +30,7 @@ libraryDependencies += "com.lihaoyi" %% "os-lib" % "0.9.1"
In your `build.sc` file, you can add a dependency on the Toolkit:
```scala
object example extends ScalaModule {
- def scalaVersion = "3.3.3"
+ def scalaVersion = "3.3.4"
def ivyDeps =
Agg(
ivy"org.scala-lang::toolkit:0.1.7"
diff --git a/_includes/_markdown/install-sttp.md b/_includes/_markdown/install-sttp.md
index 43ad70f7d9..d23cf1c09a 100644
--- a/_includes/_markdown/install-sttp.md
+++ b/_includes/_markdown/install-sttp.md
@@ -17,7 +17,7 @@ In your build.sbt file, you can add a dependency on the Toolkit:
```scala
lazy val example = project.in(file("."))
.settings(
- scalaVersion := "3.3.3",
+ scalaVersion := "3.3.4",
libraryDependencies += "org.scala-lang" %% "toolkit" % "0.1.7"
)
```
@@ -31,7 +31,7 @@ libraryDependencies += "com.softwaremill.sttp.client4" %% "core" % "4.0.0-M6"
In your build.sc file, you can add a dependency on the Toolkit:
```scala
object example extends ScalaModule {
- def scalaVersion = "3.3.3"
+ def scalaVersion = "3.3.4"
def ivyDeps =
Agg(
ivy"org.scala-lang::toolkit:0.1.7"
diff --git a/_includes/_markdown/install-upickle.md b/_includes/_markdown/install-upickle.md
index 58f3e23c9c..5ae9fb9024 100644
--- a/_includes/_markdown/install-upickle.md
+++ b/_includes/_markdown/install-upickle.md
@@ -17,7 +17,7 @@ In your build.sbt file, you can add the dependency on the Toolkit:
```scala
lazy val example = project.in(file("."))
.settings(
- scalaVersion := "3.3.3",
+ scalaVersion := "3.3.4",
libraryDependencies += "org.scala-lang" %% "toolkit" % "0.1.7"
)
```
@@ -30,7 +30,7 @@ libraryDependencies += "com.lihaoyi" %% "upickle" % "3.1.0"
In your build.sc file, you can add the dependency to the upickle library:
```scala
object example extends ScalaModule {
- def scalaVersion = "3.3.3"
+ def scalaVersion = "3.3.4"
def ivyDeps =
Agg(
ivy"org.scala-lang::toolkit:0.1.7"
diff --git a/_includes/markdown.html b/_includes/markdown.html
index cd79243a41..886b1560cd 100644
--- a/_includes/markdown.html
+++ b/_includes/markdown.html
@@ -1,3 +1 @@
-{%if include.selector%}<{{include.selector}} {%if include.classes%}class="{{include.classes}}"{%endif%} {%if include.id%}id="{{include.id}}{%endif%}">{%endif%}
- {% capture markdown %}{% include {{include.path}} %}{% endcapture %}{{ markdown | markdownify }}
-{%if include.selector%}{{include.selector}}>{%endif%}
+{% capture markdown %}{% include {{include.path}} %}{% endcapture %}{{ markdown | markdownify }}
diff --git a/_includes/online-courses-box.html b/_includes/online-courses-box.html
new file mode 100644
index 0000000000..ef06306b9b
--- /dev/null
+++ b/_includes/online-courses-box.html
@@ -0,0 +1,12 @@
+
+
+{% comment %}
+
+NOTE: Hopefully someone with more Python experience can give this a thorough review.
+
+NOTE: On this page (https://contributors.scala-lang.org/t/feedback-sought-optional-braces/4702/10), Li Haoyi comments: “Python’s success also speaks for itself; beginners certainly don’t pick Python because of performance, ease of installation, packaging, IDE support, or simplicity of the language’s runtime semantics!” I’m not a Python expert, so these points are good to know, though I don’t want to go negative in any comparisons.
+It’s more like thinking, “Python developers will appreciate Scala’s performance, ease of installation, packaging, IDE support, etc.”
+{% endcomment %}
+
+{% comment %}
+TODO: We should probably go through this document and add links to our other detail pages, when time permits.
+{% endcomment %}
+
+このセクションでは、PythonとScalaのプログラミング言語を比較します。
+Pythonに詳しくて、Scalaについて学びたいと考えているプログラマーを対象としています。具体的には、Pythonの言語機能とScalaの比較例を挙げて説明します。
+
+## はじめに
+
+例に入る前に、この最初のセクションでは、後に続くセクションの簡単な紹介と概要を提供します。
+まず、2つの言語の概要を高レベルで比較し、その後、実践的なプログラミングでの比較を行います。
+
+### 高レベルでの類似点
+
+高レベルで見ると、ScalaはPythonと以下のような *類似点* を共有しています。
+
+- 高水準プログラミング言語であり、ポインタや手動でのメモリ管理といった低レベルの概念を気にする必要がありません。
+- 比較的シンプルで簡潔な構文を持ちます。
+- [関数型プログラミングスタイル][fp-intro]をサポートしています。
+- オブジェクト指向プログラミング(OOP)言語です。
+- 内包表記(comprehensions)をサポートしています。Pythonにはリスト内包表記があり、Scalaには`for`内包表記があります。
+- ラムダ式と[高階関数][hofs]をサポートしています。
+- [Apache Spark](https://spark.apache.org)を用いたビッグデータ処理に使用できます。
+- 優れたライブラリが豊富に使用できます。
+
+### 高レベルでの相違点
+
+高レベルで見ると、PythonとScalaの間には以下のような _相違点_ があります:
+
+- Python は動的型付け言語であり、Scala は静的型付け言語です。
+ - Pythonは動的型付けですが、型ヒントによる「段階的型付け」をサポートしており、`mypy`のような静的型チェッカーで検証できます。
+ - Scalaは静的型付けですが、型推論のような機能により動的言語のような感覚で書けます。
+- Pythonはインタプリタ型で実行され、Scalaのコードはコンパイルされて _.class_ ファイルになり、Java仮想マシン(JVM)上で動作します。
+- JVMでの実行に加えて、[Scala.js](https://www.scala-js.org)によりScalaをJavaScriptの代替として使用することもできます。
+- [Scala Native](https://scala-native.org/)では、「システムレベル」のコードを記述し、ネイティブ実行ファイルにコンパイルできます。
+- Scalaではすべてが _式_ である:`if`文、`for`ループ、`match`式、さらには`try`/`catch`式でさえも、戻り値を持ちます。
+- 慣用的に Scala では不変性を基本とする:不変変数や不変コレクションを使用することが推奨されています。
+- Scalaは[並行・並列プログラミング][concurrency]のサポートが優れています。
+
+### プログラミングレベルでの類似点
+
+このセクションでは、実際に Python と Scala でコードを書く際に見られる類似点を紹介します。
+
+- Scalaの型推論により、動的型付け言語のような感覚でコーディングできます。
+- どちらの言語も式の末尾にセミコロンを使用しません。
+- 中括弧や括弧ではなく、インデントを重要視した記述がサポートされています。
+- メソッド定義の構文が似ています。
+- 両方ともリスト、辞書(マップ)、セット、タプルをサポートしています。
+- マッピングやフィルタリングに対応した内包表記を備えています。
+- 優れたIDEサポートがあります。
+- Scala 3の[トップレベル定義][toplevel]を利用することで、メソッドやフィールド、その他の定義をどこにでも記述できます。
+ - 一方で、Pythonはメソッドを1つも宣言しなくても動作できますが、Scala 3ではトップレベルですべてを実現することはできません。たとえば、Scalaアプリケーションを開始するには[mainメソッド][main-method](`@main def`)が必要です。
+
+### プログラミングレベルでの違い
+
+プログラミングレベルでも、コードを書く際に日常的に見られるいくつかの違いがあります:
+
+- Scalaでのプログラミングは非常に一貫性があります:
+ - フィールドやパラメータを定義する際に、`val`と`var`が一貫して使用されます
+ - リスト、マップ、セット、タプルはすべて同様に作成・アクセスされます。たとえば、他のScalaクラスを作成するのと同様に、すべてのタイプを作成するために括弧が使用されます---`List(1,2,3)`, `Set(1,2,3)`, `Map(1->"one")`
+ - [コレクションクラス][collections-classes] は一般的にほとんど同じ高階関数を持っています
+ - パターンマッチングは言語全体で一貫して使用されます
+ - メソッドに渡される関数を定義するために使用される構文は、匿名関数を定義するために使用される構文と同じです
+- Scalaの変数やパラメータは`val`(不変)または `var`(可変)キーワードで定義されます
+- 慣用的に、Scala では不変データ構造を使うことを良しとします。
+- コメント: Pythonはコメントに `#` を使用しますが、ScalaはC、C++、Javaスタイルの `//`、`/*...*/`、および `/**...*/` を使用します
+- 命名規則: Pythonの標準は `my_list` のようにアンダースコアを使用しますが、Scalaは `myList` を使用します
+- Scalaは静的型付けであるため、メソッドパラメータ、メソッドの戻り値、その他の場所で型を宣言します
+- パターンマッチングと `match` 式はScalaで広範に使用されており、コードの書き方を変えるでしょう
+- トレイト(Traits): Scalaではトレイトが多用され、Pythonではインターフェースや抽象クラスがあまり使用されません
+- Scalaの[コンテキスト抽象][contextual]と _型推論_ は、さまざまな機能のコレクションを提供します:
+ - [拡張メソッド][extension-methods] により、明確な構文を使用してクラスに新しい機能を簡単に追加できます
+ - [多元的等価性][multiversal] により、コンパイル時に意味のある比較にのみ等価比較を制限できます
+- Scalaには最先端のオープンソース関数型プログラミングライブラリがあります([“Awesome Scala”リスト](https://github.com/lauris/awesome-scala)を参照)
+- オブジェクト、名前渡しパラメータ、中置表記、オプションの括弧、拡張メソッド、高階関数などの機能により、独自の「制御構造」やDSLを作成できます
+- ScalaコードはJVM上で実行でき、[Scala Native](https://github.com/scala-native/scala-native)や[GraalVM](https://www.graalvm.org)を使用してネイティブイメージにコンパイルすることも可能で、高性能を実現します
+- その他多くの機能:コンパニオンクラスとオブジェクト、マクロ、数値リテラル、複数のパラメータリスト、[交差型][intersection-types]、型レベルプログラミングなど
+
+### 機能の比較と例
+
+この導入に基づき、以下のセクションではPythonとScalaのプログラミング言語機能を並べて比較します。
+
+{% comment %} TODO: Pythonの例をスペース四つに更新します。開始しましたが、別のPRで行う方が良いと思いました。 {% endcomment %}
+
+## コメント
+
+Pythonはコメントに # を使用しますが、Scalaのコメント構文はC、C++、Javaなどの言語と同じです。
+
+
+
+
+
+ # a comment
+ |
+
+
+
+ // a comment
+ /* ... */
+ /** ... */
+ |
+
+
+
+
+## 変数の割り当て
+
+これらの例は、PythonとScalaで変数を作成する方法を示しています。
+
+### 整数変数,文字列変数
+
+
+
+
+
+ x = 1
+ x = "Hi"
+ y = """foo
+ bar
+ baz"""
+ |
+
+
+
+ val x = 1
+ val x = "Hi"
+ val y = """foo
+ bar
+ baz"""
+ |
+
+
+
+
+### リスト
+
+
+
+
+
+ x = [1,2,3]
+ |
+
+
+
+ val x = List(1,2,3)
+ |
+
+
+
+
+### 辞書/マップ
+
+
+
+
+
+ x = {
+ "Toy Story": 8.3,
+ "Forrest Gump": 8.8,
+ "Cloud Atlas": 7.4
+ }
+ |
+
+
+
+ val x = Map(
+ "Toy Story" -> 8.3,
+ "Forrest Gump" -> 8.8,
+ "Cloud Atlas" -> 7.4
+ )
+ |
+
+
+
+
+### 集合
+
+
+
+
+
+ x = {1,2,3}
+ |
+
+
+
+ val x = Set(1,2,3)
+ |
+
+
+
+
+### タプル
+
+
+
+
+
+ x = (11, "Eleven")
+ |
+
+
+
+ val x = (11, "Eleven")
+ |
+
+
+
+
+Scalaのフィールドが可変になる場合は、変数定義に `val` の代わりに `var` を使います。
+
+```scala
+var x = 1
+x += 1
+```
+
+しかし、Scalaの慣習として、特に変数を変更する必要がない限り、常に`val`を使います。
+
+## 関数型プログラミングスタイルのレコード
+
+Scalaのケース・クラスはPythonのフローズン・データクラスに似ています。
+
+### 構造体の定義
+
+
+
+
+
+ from dataclasses import dataclass, replace
+
+ @dataclass(frozen=True)
+ class Person:
+ name: str
+ age: int
+ |
+
+
+
+ case class Person(name: String, age: Int)
+ |
+
+
+
+
+### インスタンスを作成して使用する
+
+
+
+
+
+ p = Person("Alice", 42)
+ p.name # Alice
+ p2 = replace(p, age=43)
+ |
+
+
+
+ val p = Person("Alice", 42)
+ p.name // Alice
+ val p2 = p.copy(age = 43)
+ |
+
+
+
+
+## オブジェクト指向プログラミングスタイルのクラスとメソッド
+
+このセクションでは、オブジェクト指向プログラミングスタイルのクラスとメソッドに関する機能の比較を行います。
+
+### クラスとプライマリーコンストラクタ
+
+
+
+
+
+ class Person(object):
+ def __init__(self, name):
+ self.name = name
+
+ def speak(self):
+ print(f'Hello, my name is {self.name}')
+ |
+
+
+
+ class Person (var name: String):
+ def speak() = println(s"Hello, my name is $name")
+ |
+
+
+
+
+### インスタンスを作成して使用する
+
+
+
+
+
+ p = Person("John")
+ p.name # John
+ p.name = 'Fred'
+ p.name # Fred
+ p.speak()
+ |
+
+
+
+ val p = Person("John")
+ p.name // John
+ p.name = "Fred"
+ p.name // Fred
+ p.speak()
+ |
+
+
+
+
+### 1行メソッド
+
+
+
+
+
+ def add(a, b): return a + b
+ |
+
+
+
+ def add(a: Int, b: Int): Int = a + b
+ |
+
+
+
+
+### 複数行のメソッド
+
+
+
+
+
+ def walkThenRun():
+ print('walk')
+ print('run')
+ |
+
+
+
+ def walkThenRun() =
+ println("walk")
+ println("run")
+ |
+
+
+
+
+## インターフェース、トレイト、継承
+
+Java 8以降に慣れていれば、ScalaのtraitはJavaのインターフェースに良く似ていることに気づくと思います。
+Pythonのインターフェース(プロトコル)や抽象クラスがあまり使われないのに対して、Scalaではトレイトが常に使われています。
+したがって、この例では両者を比較するのではなく、Scalaのトレイトを使って数学のちょっとした問題を解く方法を紹介します:
+
+```scala
+trait Adder:
+ def add(a: Int, b: Int) = a + b
+
+trait Multiplier:
+ def multiply(a: Int, b: Int) = a * b
+
+// create a class from the traits
+class SimpleMath extends Adder, Multiplier
+val sm = new SimpleMath
+sm.add(1,1) // 2
+sm.multiply(2,2) // 4
+```
+
+クラスやオブジェクトでtraitを使う方法は他にも[たくさんあります][modeling-intro]。
+しかし、これは概念を論理的な動作のグループに整理して、完全な解答を作成するために必要に応じてそれらを統合するために、どのように使うことができるかのちょっとしたアイデアを与えてくれます。
+
+## 制御構文
+
+ここではPythonとScalaの[制御構文][control-structures]を比較します。
+どちらの言語にも `if`/`else`, `while`, `for` ループ、 `try` といった構文があります。
+加えて、Scala には `match` 式があります。
+
+### `if` 文, 1行
+
+
+
+
+
+ if x == 1: print(x)
+ |
+
+
+
+ if x == 1 then println(x)
+ |
+
+
+
+
+### `if` 文, 複数行
+
+
+
+
+
+ if x == 1:
+ print("x is 1, as you can see:")
+ print(x)
+ |
+
+
+
+ if x == 1 then
+ println("x is 1, as you can see:")
+ println(x)
+ |
+
+
+
+
+### if, else if, else:
+
+
+
+
+
+ if x < 0:
+ print("negative")
+ elif x == 0:
+ print("zero")
+ else:
+ print("positive")
+ |
+
+
+
+ if x < 0 then
+ println("negative")
+ else if x == 0 then
+ println("zero")
+ else
+ println("positive")
+ |
+
+
+
+
+### `if` 文からの戻り値
+
+
+
+
+
+ min_val = a if a < b else b
+ |
+
+
+
+ val minValue = if a < b then a else b
+ |
+
+
+
+
+### メソッドの本体としての`if`
+
+
+
+
+
+ def min(a, b):
+ return a if a < b else b
+ |
+
+
+
+ def min(a: Int, b: Int): Int =
+ if a < b then a else b
+ |
+
+
+
+
+### `while` ループ
+
+
+
+
+
+ i = 1
+ while i < 3:
+ print(i)
+ i += 1
+ |
+
+
+
+ var i = 1
+ while i < 3 do
+ println(i)
+ i += 1
+ |
+
+
+
+
+### rangeを指定した`for` ループ
+
+
+
+
+
+ for i in range(0,3):
+ print(i)
+ |
+
+
+
+ // preferred
+ for i <- 0 until 3 do println(i)
+
+ // also available
+ for (i <- 0 until 3) println(i)
+
+ // multiline syntax
+ for
+ i <- 0 until 3
+ do
+ println(i)
+ |
+
+
+
+
+### リスト範囲内の`for` ループ
+
+
+
+
+
+ for i in ints: print(i)
+
+ for i in ints:
+ print(i)
+ |
+
+
+
+ for i <- ints do println(i)
+ |
+
+
+
+
+### 複数行での`for` ループ
+
+
+
+
+
+ for i in ints:
+ x = i * 2
+ print(f"i = {i}, x = {x}")
+ |
+
+
+
+ for
+ i <- ints
+ do
+ val x = i * 2
+ println(s"i = $i, x = $x")
+ |
+
+
+
+
+### 複数の “range” ジェネレータ
+
+
+
+
+
+ for i in range(1,3):
+ for j in range(4,6):
+ for k in range(1,10,3):
+ print(f"i = {i}, j = {j}, k = {k}")
+ |
+
+
+
+ for
+ i <- 1 to 2
+ j <- 4 to 5
+ k <- 1 until 10 by 3
+ do
+ println(s"i = $i, j = $j, k = $k")
+ |
+
+
+
+
+### ガード付きジェネレータ (`if` 式)
+
+
+
+
+
+ for i in range(1,11):
+ if i % 2 == 0:
+ if i < 5:
+ print(i)
+ |
+
+
+
+ for
+ i <- 1 to 10
+ if i % 2 == 0
+ if i < 5
+ do
+ println(i)
+ |
+
+
+
+
+### 行ごとに複数の`if`条件
+
+
+
+
+
+ for i in range(1,11):
+ if i % 2 == 0 and i < 5:
+ print(i)
+ |
+
+
+
+ for
+ i <- 1 to 10
+ if i % 2 == 0 && i < 5
+ do
+ println(i)
+ |
+
+
+
+
+### 内包表記
+
+
+
+
+
+ xs = [i * 10 for i in range(1, 4)]
+ # xs: [10,20,30]
+ |
+
+
+
+ val xs = for i <- 1 to 3 yield i * 10
+ // xs: Vector(10, 20, 30)
+ |
+
+
+
+
+### `match` 条件式
+
+
+
+
+
+ # From 3.10, Python supports structural pattern matching
+ # You can also use dictionaries for basic “switch” functionality
+ match month:
+ case 1:
+ monthAsString = "January"
+ case 2:
+ monthAsString = "February"
+ case _:
+ monthAsString = "Other"
+ |
+
+
+
+ val monthAsString = month match
+ case 1 => "January"
+ case 2 => "February"
+ _ => "Other"
+ |
+
+
+
+
+### switch/match
+
+
+
+
+
+ # Only from Python 3.10
+ match i:
+ case 1 | 3 | 5 | 7 | 9:
+ numAsString = "odd"
+ case 2 | 4 | 6 | 8 | 10:
+ numAsString = "even"
+ case _:
+ numAsString = "too big"
+ |
+
+
+
+ val numAsString = i match
+ case 1 | 3 | 5 | 7 | 9 => "odd"
+ case 2 | 4 | 6 | 8 | 10 => "even"
+ case _ => "too big"
+ |
+
+
+
+
+### try, catch, finally
+
+
+
+
+
+ try:
+ print(a)
+ except NameError:
+ print("NameError")
+ except:
+ print("Other")
+ finally:
+ print("Finally")
+ |
+
+
+
+ try
+ writeTextToFile(text)
+ catch
+ case ioe: IOException =>
+ println(ioe.getMessage)
+ case fnf: FileNotFoundException =>
+ println(fnf.getMessage)
+ finally
+ println("Finally")
+ |
+
+
+
+
+マッチ式とパターンマッチは、Scalaプログラミングの大きな要素ですが、ここで紹介しているのは、マッチ式の機能の一部だけです。より多くの例については、[制御構造][control-structures]のページをご覧ください。
+
+## コレクションクラス
+
+このセクションでは、PythonとScalaで利用可能なコレクションクラス[collections classes][collections-classes]を比較します。リスト、辞書/マップ、セット、タプルなどです。
+
+### リスト
+
+Pythonにはリストがあるように、Scalaにはニーズに応じて、可変および不可変な列(Seq)のクラスがいくつか用意されています。
+Pythonのリストは変更可能であるため、Scalaの `ArrayBuffer` によく似ています。
+
+### Pythonリスト & Scalaの列(Seq)
+
+
+
+
+
+ a = [1,2,3]
+ |
+
+
+
+ // use different sequence classes
+ // as needed
+ val a = List(1,2,3)
+ val a = Vector(1,2,3)
+ val a = ArrayBuffer(1,2,3)
+ |
+
+
+
+
+### リストの要素へのアクセス
+
+
+
+
+
+ a[0] a[1]
+ |
+
+
+
+ a(0) a(1) // just like all other method calls
+ |
+
+
+
+
+### リストの要素の更新
+
+
+
+
+
+ a[0] = 10
+ a[1] = 20
+ |
+
+
+
+ // ArrayBuffer is mutable
+ a(0) = 10
+ a(1) = 20
+ |
+
+
+
+
+### 2つのリストの結合
+
+
+
+
+
+ c = a + b
+ |
+
+
+
+ val c = a ++ b
+ |
+
+
+
+
+### リストの反復処理
+
+
+
+
+
+ for i in ints: print(i)
+
+ for i in ints:
+ print(i)
+ |
+
+
+
+ // preferred
+ for i <- ints do println(i)
+
+ // also available
+ for (i <- ints) println(i)
+ |
+
+
+
+
+Scala の主な列(Seq)クラスは `List`、`Vector`、`ArrayBuffer` です。
+`List` と `Vector` は不変な列が必要なときに使うメインクラスで、 `ArrayBuffer` は可変な列が必要なときに使うメインクラスです。
+(Scala における 「バッファ」 とは、大きくなったり小さくなったりする配列のことです。)
+
+### 辞書/マップ
+
+Python の辞書はScala の `Map` クラスのようなものです。
+しかし、Scala のデフォルトのマップは _immutable_ であり、新しいマップを簡単に作成するための変換メソッドを持っています。
+
+#### 辞書/マップ の作成
+
+
+
+
+
+ my_dict = {
+ 'a': 1,
+ 'b': 2,
+ 'c': 3
+ }
+ |
+
+
+
+ val myMap = Map(
+ "a" -> 1,
+ "b" -> 2,
+ "c" -> 3
+ )
+ |
+
+
+
+
+#### 辞書/マップの要素へのアクセス
+
+
+
+
+
+ my_dict['a'] # 1
+ |
+
+
+
+ myMap("a") // 1
+ |
+
+
+
+
+#### `for` ループでの辞書/マップ
+
+
+
+
+
+ for key, value in my_dict.items():
+ print(key)
+ print(value)
+ |
+
+
+
+ for (key,value) <- myMap do
+ println(key)
+ println(value)
+ |
+
+
+
+
+Scalaには、さまざまなニーズに対応する他の専門的な `Map` クラスがあります。
+
+### 集合
+
+Pythonの集合は、_mutable_ Scalaの`Set`クラスに似ています。
+
+#### 集合の作成
+
+
+
+
+
+ set = {"a", "b", "c"}
+ |
+
+
+
+ val set = Set(1,2,3)
+ |
+
+
+
+
+#### 重複する要素
+
+
+
+
+
+ set = {1,2,1}
+ # set: {1,2}
+ |
+
+
+
+ val set = Set(1,2,1)
+ // set: Set(1,2)
+ |
+
+
+
+
+Scalaには、他にも様々なニーズに特化した`Set`クラスがあります。
+
+### タプル
+
+PythonとScalaのタプルも似ています。
+
+#### タプルの作成
+
+
+
+
+
+ t = (11, 11.0, "Eleven")
+ |
+
+
+
+ val t = (11, 11.0, "Eleven")
+ |
+
+
+
+
+#### タプルの要素へのアクセス
+
+
+
+
+
+ t[0] # 11
+ t[1] # 11.0
+ |
+
+
+
+ t(0) // 11
+ t(1) // 11.0
+ |
+
+
+
+
+## コレクションクラスでのメソッド
+
+PythonとScalaには、同じ関数型メソッドがいくつかあります。
+
+- `map`
+- `filter`
+- `reduce`
+
+Pythonのラムダ式でこれらのメソッドを使うのに慣れていれば、Scalaがコレクション・クラスのメソッドで同じようなアプローチを持っていることがわかると思います。
+この機能を実証するために、ここに2つのサンプルリストを示します。
+
+```scala
+numbers = [1,2,3] // python
+val numbers = List(1,2,3) // scala
+```
+
+これらのリストは以下の表で使用され、マップ処理とフィルター処理のアルゴリズムを適用する方法を示しています。
+
+### マップ処理の内包表記
+
+
+
+
+
+ x = [i * 10 for i in numbers]
+ |
+
+
+
+ val x = for i <- numbers yield i * 10
+ |
+
+
+
+
+### フィルター処理の内包表記
+
+
+
+
+
+ evens = [i for i in numbers if i % 2 == 0]
+ |
+
+
+
+ val evens = numbers.filter(_ % 2 == 0)
+ // or
+ val evens = for i <- numbers if i % 2 == 0 yield i
+ |
+
+
+
+
+### マップ、フィルター処理の内包表記
+
+
+
+
+
+ x = [i * 10 for i in numbers if i % 2 == 0]
+ |
+
+
+
+ val x = numbers.filter(_ % 2 == 0).map(_ * 10)
+ // or
+ val x = for i <- numbers if i % 2 == 0 yield i * 10
+ |
+
+
+
+
+### マップ処理
+
+
+
+
+
+ x = map(lambda x: x * 10, numbers)
+ |
+
+
+
+ val x = numbers.map(_ * 10)
+ |
+
+
+
+
+### フィルター処理
+
+
+
+
+
+ f = lambda x: x > 1
+ x = filter(f, numbers)
+ |
+
+
+
+ val x = numbers.filter(_ > 1)
+ |
+
+
+
+
+
+### Scalaのコレクションメソッド
+
+Scalaのコレクションクラスには100以上の関数メソッドがあり、コードを簡単にすることができます。
+Python では、これらの関数の一部は `itertools` モジュールで利用できます。
+`map`、`filter`、`reduce` に加えて、Scala でよく使われるメソッドを以下に示します。
+これらのメソッドの例では
+
+- `c` はコレクションです。
+- `p` は述語です。
+- `f` は関数、無名関数、またはメソッドです。
+- `n` は整数値です。
+
+これらは利用可能なフィルタリング方法の一部です。
+
+|メソッド|説明|
+| -------------- | ------------- |
+| `c1.diff(c2)` | `c1` と `c2` の要素の差分を返します。|
+| `c.distinct` | `c` の重複しない要素を返します。|
+| `c.drop(n)` | 最初の `n` 要素を除くコレクションのすべての要素を返します。|
+| `c.filter(p)` | コレクションから、その述語が `true` となるすべての要素を返します。|
+| `c.head` | コレクションの最初の要素を返します。 (コレクションが空の場合は `NoSuchElementException` をスローします。)|
+| `c.tail` | コレクションから最初の要素を除くすべての要素を返します。 (コレクションが空の場合は `UnsupportedOperationException` をスローします。)|
+| `c.take(n)` | コレクション `c` の最初の `n` 個の要素を返します。
+以下に、いくつかのトランスフォーマメソッドを示します。|
+|メソッド| 説明 |
+| --------------- | -------------
+| `c.flatten` | コレクションのコレクション(リストのリストなど)を単一のコレクション(単一のリスト)に変換します。|
+| `c.flatMap(f)` | コレクション `c` のすべての要素に `f` を適用し(`map` のような動作)、その結果のコレクションの要素を平坦化して、新しいコレクションを返します。|
+| `c.map(f)` | コレクション `c` のすべての要素に `f` を適用して、新しいコレクションを作成します。|
+| `c.reduce(f)` | 「リダクション」関数 `f` を `c` の連続する要素に適用し、単一の値を生成します。|
+| `c.sortWith(f)` | 比較関数 `f` によってソートされた `c` のバージョンを返します。|
+よく使われるグループ化メソッド:
+| メソッド | 説明 |
+| ---------------- | -------------
+| `c.groupBy(f)` | コレクションを `f` に従って分割し、コレクションの `Map` を作成します。|
+| `c.partition(p)` | 述語 `p` に従って2つのコレクションを返します。|
+| `c.span(p)` | 2つのコレクションからなるコレクションを返します。1つ目は `c.takeWhile(p)` によって作成され、2つ目は `c.dropWhile(p)` によって作成されます。|
+| `c.splitAt(n)` | コレクション `c` を要素 `n` で分割して、2つのコレクションからなるコレクションを返します。|
+情報および数学的なメソッド:
+| メソッド | 説明 |
+| -------------- | ------------- |
+| `c1.containsSlice(c2)` | `c1` がシーケンス `c2` を含む場合に `true` を返します。|
+| `c.count(p)` | `p` が `true` である `c` の要素数を数えます。|
+| `c.distinct` | `c` の一意な要素を返します。|
+| `c.exists(p)` | コレクション内のいずれかの要素に対して `p` が `true` であれば `true` を返します。|
+| `c.find(p)` | `p` に一致する最初の要素を返します。 要素は `Option[A]` として返されます。|
+| `c.min` | コレクションから最小の要素を返します。 (_java.lang.UnsupportedOperationException_例外が発生する場合があります。)|
+| `c.max` | コレクションから最大の要素を返します。 (_java.lang.UnsupportedOperationException_例外が発生する場合があります。)|
+| `c slice(from, to)` | 要素 `from` から始まり、要素 `to` で終わる要素の範囲を返します。|
+| `c.sum` | コレクション内のすべての要素の合計を返しますw。 (コレクション内の要素に対して `Ordering` を定義する必要があります。)|
+
+以下に、これらのメソッドがリスト上でどのように機能するかを説明する例をいくつか示します。
+
+```scala
+val a = List(10, 20, 30, 40, 10) // List(10, 20, 30, 40, 10)
+a.distinct // List(10, 20, 30, 40)
+a.drop(2) // List(30, 40, 10)
+a.dropRight(2) // List(10, 20, 30)
+a.dropWhile(_ < 25) // List(30, 40, 10)
+a.filter(_ < 25) // List(10, 20, 10)
+a.filter(_ > 100) // List()
+a.find(_ > 20) // Some(30)
+a.head // 10
+a.headOption // Some(10)
+a.init // List(10, 20, 30, 40)
+a.intersect(List(19,20,21)) // List(20)
+a.last // 10
+a.lastOption // Some(10)
+a.slice(2,4) // List(30, 40)
+a.tail // List(20, 30, 40, 10)
+a.take(3) // List(10, 20, 30)
+a.takeRight(2) // List(40, 10)
+a.takeWhile(_ < 30) // List(10, 20)
+```
+
+これらのメソッドは、Scalaにおける共通のパターンを示しています。オブジェクト上で利用可能な機能メソッドです。
+これらの方法はいずれも、初期リスト `a` を変更しません。代わりに、コメントの後に示されているデータをすべて返します。
+利用可能なメソッドは他にもたくさんありますが、これらの説明と例が、組み込みのコレクションメソッドの持つ力を実感する一助となれば幸いです。
+
+## 列挙
+
+このセクションでは、PythonとScala 3の列挙型を比較します。
+
+### 列挙型の作成
+
+
+
+
+
+ from enum import Enum, auto
+ class Color(Enum):
+ RED = auto()
+ GREEN = auto()
+ BLUE = auto()
+ |
+
+
+
+ enum Color:
+ case Red, Green, Blue
+ |
+
+
+
+
+### 値とその比較
+
+
+
+
+
+ Color.RED == Color.BLUE # False
+ |
+
+
+
+ Color.Red == Color.Blue // false
+ |
+
+
+
+
+### パラメータ化された列挙型
+
+
+
+
+
+ N/A
+ |
+
+
+
+ enum Color(val rgb: Int):
+ case Red extends Color(0xFF0000)
+ case Green extends Color(0x00FF00)
+ case Blue extends Color(0x0000FF)
+ |
+
+
+
+
+### ユーザー定義による列挙メンバー
+
+
+
+
+
+ N/A
+ |
+
+
+
+ enum Planet(
+ mass: Double,
+ radius: Double
+ ):
+ case Mercury extends
+ Planet(3.303e+23, 2.4397e6)
+ case Venus extends
+ Planet(4.869e+24, 6.0518e6)
+ case Earth extends
+ Planet(5.976e+24, 6.37814e6)
+ // more planets ...
+
+ // fields and methods
+ private final val G = 6.67300E-11
+ def surfaceGravity = G * mass /
+ (radius * radius)
+ def surfaceWeight(otherMass: Double)
+ = otherMass * surfaceGravity
+ |
+
+
+
+
+## Scala 独自の概念
+
+Scalaには、Pythonには現在同等の機能がない概念が他にもあります。
+詳細は以下のリンクを参照してください。
+- 拡張メソッド(extension methods)、型クラス(type classes)、暗黙的値(implicit values)など、文脈依存の抽象化(contextual abstractions)に関連するほとんどの概念
+- Scalaでは複数のパラメータリストを使用できるため、部分適用関数などの機能や独自のDSLを作成することが可能
+- 独自の制御構造や DSL を作成できる機能
+- [多様等価][多様等価]: どの等価比較が意味を持つかをコンパイル時に制御できる機能
+- インフィックスメソッド
+- マクロ
+
+## Scala と仮想環境
+
+Scalaでは、Pythonの仮想環境に相当するものを明示的に設定する必要はありません。デフォルトでは、Scalaのビルドツールがプロジェクトの依存関係を管理するため、ユーザーは手動でパッケージをインストールする必要がありません。例えば、`sbt`ビルドツールを使用する場合、`build.sbt`ファイルの`libraryDependencies`設定で依存関係を指定し、
+
+```
+cd myapp
+sbt compile
+```
+
+以上のコマンドを実行することで、その特定のプロジェクトに必要なすべての依存関係が自動的に解決されます。
+ダウンロードされた依存関係の場所は、主にビルドツールの実装の詳細であり、ユーザーはこれらのダウンロードされた依存関係と直接やりとりする必要はありません。
+例えば、sbtの依存関係キャッシュ全体を削除した場合、プロジェクトの次のコンパイル時には、sbtが自動的に必要な依存関係をすべて解決し、ダウンロードし直します。
+これはPythonとは異なります。Pythonではデフォルトで依存関係がシステム全体またはユーザー全体のディレクトリにインストールされるため、プロジェクトごとに独立した環境を取得するには、対応する仮想環境を作成する必要があります。
+例えば、`venv`モジュールを使用して、特定のプロジェクト用に次のように仮想環境を作成できます。
+
+```
+cd myapp
+python3 -m venv myapp-env
+source myapp-env/bin/activate
+pip install -r requirements.txt
+```
+
+これにより、プロジェクトの `myapp/myapp-env` ディレクトリにすべての依存関係がインストールされ、シェル環境変数 `PATH` が変更されて、依存関係が `myapp-env` から参照されるようになります。
+Scalaでは、このような手動での作業は一切必要ありません。
+
+[collections-classes]: {% link _overviews/scala3-book/collections-classes.md %}
+[concurrency]: {% link _overviews/scala3-book/concurrency.md %}
+[contextual]: {% link _overviews/scala3-book/ca-contextual-abstractions-intro.md %}
+[control-structures]: {% link _overviews/scala3-book/control-structures.md %}
+[extension-methods]: {% link _overviews/scala3-book/ca-extension-methods.md %}
+[fp-intro]: {% link _overviews/scala3-book/fp-intro.md %}
+[hofs]: {% link _overviews/scala3-book/fun-hofs.md %}
+[intersection-types]: {% link _overviews/scala3-book/types-intersection.md %}
+[main-method]: {% link _overviews/scala3-book/methods-main-methods.md %}
+[modeling-intro]: {% link _overviews/scala3-book/domain-modeling-intro.md %}
+[multiversal]: {% link _overviews/scala3-book/ca-multiversal-equality.md %}
+[toplevel]: {% link _overviews/scala3-book/taste-toplevel-definitions.md %}
+[type-classes]: {% link _overviews/scala3-book/ca-type-classes.md %}
+[union-types]: {% link _overviews/scala3-book/types-union.md %}
+
diff --git a/_ja/overviews/scala3-book/scala4x.css b/_ja/overviews/scala3-book/scala4x.css
new file mode 100644
index 0000000000..1772c03ac8
--- /dev/null
+++ b/_ja/overviews/scala3-book/scala4x.css
@@ -0,0 +1,54 @@
+
+
+
diff --git a/_ja/tour/tour-of-scala.md b/_ja/tour/tour-of-scala.md
index 9e5d2b9860..70c1e0f522 100644
--- a/_ja/tour/tour-of-scala.md
+++ b/_ja/tour/tour-of-scala.md
@@ -13,7 +13,7 @@ next-page: basics
これはほんの短いツアーで、完全な言語のチュートリアルではありません。
もしそれを望むなら、[こちらの本](/books.html) を手に入れるか、
-[その他の解決手段](/learn.html) での相談を検討してください。
+[その他の解決手段](/online-courses.html) での相談を検討してください。
## Scalaとは?
Scalaは一般的なプログラミング方法を簡潔かつエレガントかつ型安全な方法で表現するために設計されたモダンなマルチパラダイム言語です。
diff --git a/_ko/tour/tour-of-scala.md b/_ko/tour/tour-of-scala.md
index 0c83ea5e0c..0bf0b28232 100644
--- a/_ko/tour/tour-of-scala.md
+++ b/_ko/tour/tour-of-scala.md
@@ -12,7 +12,7 @@ next-page: basics
## 투어를 환영합니다
이 투어에서는 스칼라에서 가장 자주 사용되는 기능을 요약하여 소개하며, 스칼라 초보자를 대상으로 합니다.
-언어 전체를 다루는 튜토리얼이 아닌 간단히 둘러보기입니다. 자세히 다루고 싶다면, [책](/books.html)을 구하거나 [다른 자료](/learn.html)를 찾아보세요.
+언어 전체를 다루는 튜토리얼이 아닌 간단히 둘러보기입니다. 자세히 다루고 싶다면, [책](/books.html)을 구하거나 [다른 자료](/online-courses.html)를 찾아보세요.
## 스칼라란?
스칼라는 일반적인 프로그래밍 패턴을 간결하고 우아하며 타입-세이프한 방식으로 표현할 수 있게 설계된 최신 멀티-패러다임 프로그래밍 언어입니다. 객체지향과 함수형 언어의 특징을 자연스럽게 통합합니다.
diff --git a/_layouts/online-courses.html b/_layouts/online-courses.html
new file mode 100644
index 0000000000..45addb8dfa
--- /dev/null
+++ b/_layouts/online-courses.html
@@ -0,0 +1,29 @@
+---
+layout: root-index-layout
+---
+
+
+