Skip to content

Commit 9cd040c

Browse files
committed
Add scala 3 book in russian
1 parent 4051ce8 commit 9cd040c

File tree

2 files changed

+48
-43
lines changed

2 files changed

+48
-43
lines changed

_ru/scala3/book/taste-hello-world.md

Lines changed: 40 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,14 @@ previous-page: taste-intro
1212
next-page:
1313
---
1414

15-
> **Hint**: in the following examples try picking your preferred Scala version.
15+
> **Подсказка**: в следующих примерах попробуйте выбрать предпочтительную для вас версию Scala.
1616
> <noscript><span style="font-weight: bold;">Info</span>: JavaScript is currently disabled, code tabs will still work, but preferences will not be remembered.</noscript>
1717
18-
## Your First Scala Program
18+
## Ваша первая Scala-программа
1919

2020

21-
A Scala “Hello, World!” example goes as follows.
22-
First, put this code in a file named _hello.scala_:
23-
21+
Пример “Hello, World!” на Scala выглядит следующим образом.
22+
Сначала поместите этот код в файл с именем _hello.scala_:
2423

2524
<!-- Display Hello World for each Scala Version -->
2625
{% tabs hello-world-demo class=tabs-scala-version %}
@@ -33,32 +32,33 @@ object hello {
3332
}
3433
}
3534
```
36-
> In this code, we defined a method named `main`, inside a Scala `object` named `hello`.
37-
> An `object` in Scala is similar to a `class`, but defines a singleton instance that you can pass around.
38-
> `main` takes an input parameter named `args` that must be typed as `Array[String]`, (ignore `args` for now).
35+
> В этом коде мы определили метод с именем `main` внутри Scala `object`-а с именем `hello`.
36+
> `object` в Scala похож на `class`, но определяет экземпляр singleton, который можно передать.
37+
> `main` принимает входной параметр с именем `args`, который должен иметь тип `Array[String]`
38+
> (`args` пока можно игнорировать).
3939
4040
{% endtab %}
4141

4242
{% tab 'Scala 3' for=hello-world-demo %}
4343
```scala
4444
@main def hello() = println("Hello, World!")
4545
```
46-
> In this code, `hello` is a method.
47-
> It’s defined with `def`, and declared to be a “main” method with the `@main` annotation.
48-
> It prints the `"Hello, World!"` string to standard output (STDOUT) using the `println` method.
46+
> В этом коде `hello` - это метод.
47+
> Он определяется с помощью `def` и объявляется в качестве основного метода с помощью аннотации `@main`.
48+
> Он выводит строку "Hello, World!" на стандартный вывод (STDOUT) с помощью метода `println`.
4949
5050
{% endtab %}
5151

5252
{% endtabs %}
5353
<!-- End tabs -->
5454

55-
Next, compile the code with `scalac`:
55+
Затем скомпилируйте код с помощью `scalac`:
5656

5757
```bash
5858
$ scalac hello.scala
5959
```
6060

61-
If you’re coming to Scala from Java, `scalac` is just like `javac`, so that command creates several files:
61+
Если вы переходите на Scala с Java: `scalac` похоже на `javac`, эта команда создает несколько файлов:
6262

6363
<!-- Display Hello World compiled outputs for each Scala Version -->
6464
{% tabs hello-world-outputs class=tabs-scala-version %}
@@ -87,25 +87,26 @@ hello.tasty
8787
{% endtabs %}
8888
<!-- End tabs -->
8989

90-
Like Java, the _.class_ files are bytecode files, and they’re ready to run in the JVM.
90+
Как и Java, файлы _.class_ представляют собой файлы байт-кода, и они готовы к запуску в JVM.
9191

92-
Now you can run the `hello` method with the `scala` command:
92+
Теперь вы можете запустить метод `hello` командой `scala`:
9393

9494
```bash
9595
$ scala hello
9696
Hello, World!
9797
```
9898

99-
Assuming that worked, congratulations, you just compiled and ran your first Scala application.
99+
Если запуск прошел успешно, поздравляем, вы только что скомпилировали и запустили свое первое приложение Scala.
100100

101-
> More information about sbt and other tools that make Scala development easier can be found in the [Scala Tools][scala_tools] chapter.
101+
> Дополнительную информацию о sbt и других инструментах, упрощающих разработку на Scala, можно найти в главе [Инструменты Scala][scala_tools].
102102
103-
## Ask For User Input
103+
## Запрос пользовательского ввода
104104

105-
In our next example let's ask for the user's name before we greet them!
105+
В нашем следующем примере давайте спросим имя пользователя, прежде чем приветствовать его!
106106

107-
There are several ways to read input from a command-line, but a simple way is to use the
108-
`readLine` method in the _scala.io.StdIn_ object. To use it, you need to first import it, like this:
107+
Есть несколько способов прочитать ввод из командной строки, но самый простой способ —
108+
использовать метод `readLine` из объекта _scala.io.StdIn_.
109+
Чтобы использовать этот метод, вам нужно сначала его импортировать, например:
109110

110111
{% tabs import-readline %}
111112
{% tab 'Scala 2 and 3' for=import-readline %}
@@ -115,7 +116,8 @@ import scala.io.StdIn.readLine
115116
{% endtab %}
116117
{% endtabs %}
117118

118-
To demonstrate how this works, let’s create a little example. Put this source code in a file named _helloInteractive.scala_:
119+
Чтобы продемонстрировать, как это работает, давайте создадим небольшой пример.
120+
Поместите этот исходный код в файл с именем _helloInteractive.scala_:
119121

120122
<!-- Display interactive Hello World application for each Scala Version -->
121123
{% tabs hello-world-interactive class=tabs-scala-version %}
@@ -152,26 +154,28 @@ import scala.io.StdIn.readLine
152154
{% endtabs %}
153155
<!-- End tabs -->
154156

155-
In this code we save the result of `readLine` to a variable called `name`, we then
156-
use the `+` operator on strings to join `"Hello, "` with `name` and `"!"`, making one single string value.
157+
В этом коде мы сохраняем результат из `readLine` в переменную с именем `name`,
158+
затем используем оператор над строками `+` для соединения `"Hello, "` с `name` и `"!"`, создавая одно единственное строковое значение.
157159

158-
> You can learn more about using `val` by reading [Variables and Data Types](/scala3/book/taste-vars-data-types.html).
160+
> Вы можете узнать больше об использовании val, прочитав главу [Переменные и типы данных](/scala3/book/taste-vars-data-types.html).
159161
160-
Then compile the code with `scalac`:
162+
Затем скомпилируйте код с помощью `scalac`:
161163

162164
```bash
163165
$ scalac helloInteractive.scala
164166
```
165-
Then run it with `scala helloInteractive`, this time the program will pause after asking for your name,
166-
and wait until you type a name and press return on the keyboard, looking like this:
167+
168+
Затем запустите его с помощью `scala helloInteractive`. На этот раз программа сделает паузу после запроса вашего имени
169+
и подождет, пока вы не наберете имя и не нажмете клавишу возврата на клавиатуре.
170+
Выглядит это так:
167171

168172
```bash
169173
$ scala helloInteractive
170174
Please enter your name:
171175
172176
```
173177

174-
When you enter your name at the prompt, the final interaction should look like this:
178+
Когда вы вводите свое имя в "приглашении", окончательное взаимодействие должно выглядеть так:
175179

176180
```bash
177181
$ scala helloInteractive
@@ -180,10 +184,10 @@ Alvin Alexander
180184
Hello, Alvin Alexander!
181185
```
182186

183-
### A Note about Imports
187+
### Примечание об импорте
184188

185-
As you saw in this application, sometimes certain methods, or other kinds of definitions that we'll see later,
186-
are not available unless you use an `import` clause like so:
189+
Как вы ранее видели, иногда определенные методы или другие типы определений, которые мы увидим позже, недоступны,
190+
если вы не используете подобное предложение `import`:
187191

188192
{% tabs import-readline-2 %}
189193
{% tab 'Scala 2 and 3' for=import-readline-2 %}
@@ -193,9 +197,9 @@ import scala.io.StdIn.readLine
193197
{% endtab %}
194198
{% endtabs %}
195199

196-
Imports help you write code in a few ways:
197-
- you can put code in multiple files, to help avoid clutter, and to help navigate large projects.
198-
- you can use a code library, perhaps written by someone else, that has useful functionality
199-
- you can know where a certain definition comes from (especially if it was not written in the current file).
200+
Импорт помогает писать и распределять код несколькими способами:
201+
- вы можете поместить код в несколько файлов, чтобы избежать беспорядка и облегчить навигацию в больших проектах.
202+
- вы можете использовать библиотеку кода, возможно, написанную кем-то другим, которая имеет полезную функциональность.
203+
- вы видите, откуда берется определенное определение (особенно если оно не было записано в текущем файле).
200204

201205
[scala_tools]: {% link _overviews/scala3-book/scala-tools.md %}

_ru/scala3/book/taste-intro.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,17 @@ next-page: taste-hello-world
1414

1515

1616
В этой главе представлен краткий обзор основных возможностей языка программирования Scala 3.
17-
After this initial tour, the rest of the book provides more details on these features, and the [Reference documentation][reference] provides _many_ more details.
17+
После начального ознакомления остальная часть книги содержит более подробную информацию об описанных функциях,
18+
а [справочная документация][reference] содержит массу подробностей.
1819

19-
## Setting Up Scala
20+
## Настройка Скала
2021

21-
Througout this chapter, and the rest of the book, we encourage you to try out the examples by either copying
22-
them or typing them out manually. The tools necessary to follow along with the examples on your own computer
23-
can be installed by following our [getting started guide][get-started].
22+
На протяжении этой главы и остальной части книги мы рекомендуем вам пробовать примеры, скопировав их или набрав вручную.
23+
Инструменты, необходимые для работы с примерами на вашем компьютере, можно установить,
24+
следуя нашему [руководству для началы работы со Scala][get-started].
2425

25-
> Alternatively you can run the examples in a web browser with [Scastie](https://scastie.scala-lang.org), a
26-
> fully online editor and code-runner for Scala.
26+
> В качестве альтернативы вы можете запустить примеры в веб-браузере с помощью [Scastie](https://scastie.scala-lang.org),
27+
> полного онлайн-редактора и исполнителя кода для Scala.
2728
2829

2930
[reference]: {{ site.scala3ref }}/overview.html

0 commit comments

Comments
 (0)