Skip to content

Commit dae92df

Browse files
committed
Methods without arguments translate
1 parent 0bcc5a3 commit dae92df

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

_ru/tutorials/scala-for-java-programmers.md

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -273,11 +273,11 @@ callback-функцию как аргумент. Тип этой функции
273273
программист должен хорошо понимать, когда следует опускать типы, а
274274
когда указывать их явно.
275275

276-
### Methods without arguments
276+
### Методы без аргументов
277277

278-
A small problem of the methods `re` and `im` is that, in
279-
order to call them, one has to put an empty pair of parenthesis after
280-
their name, as the following example shows:
278+
Небольшая проблема методов `re` и `im` в том, что для их вызова нужно
279+
поставить пустую пару скобок после их имени, как показано в
280+
следующем примере:
281281

282282
object ComplexNumbers {
283283
def main(args: Array[String]): Unit = {
@@ -286,13 +286,12 @@ their name, as the following example shows:
286286
}
287287
}
288288

289-
It would be nicer to be able to access the real and imaginary parts
290-
like if they were fields, without putting the empty pair of
291-
parenthesis. This is perfectly doable in Scala, simply by defining
292-
them as methods *without arguments*. Such methods differ from
293-
methods with zero arguments in that they don't have parenthesis after
294-
their name, neither in their definition nor in their use. Our
295-
`Complex` class can be rewritten as follows:
289+
Было бы лучше иметь доступ к реальным и мнимым частям, как если бы
290+
они были полями, без добавления пустой пары скобок. В Scala это
291+
можно сделать, просто определив их как методы *без аргументов*.
292+
Такие методы отличаются от методов с нулевыми аргументами тем, что
293+
у них нет скобок после имени, ни в их определении, ни в их
294+
использовании. Наш класс `Complex` можно переписать следующим образом:
296295

297296
class Complex(real: Double, imaginary: Double) {
298297
def re = real

0 commit comments

Comments
 (0)