@@ -273,11 +273,11 @@ callback-функцию как аргумент. Тип этой функции
273
273
программист должен хорошо понимать, когда следует опускать типы, а
274
274
когда указывать их явно.
275
275
276
- ### Methods without arguments
276
+ ### Методы без аргументов
277
277
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
+ следующем примере :
281
281
282
282
object ComplexNumbers {
283
283
def main(args: Array[String]): Unit = {
@@ -286,13 +286,12 @@ their name, as the following example shows:
286
286
}
287
287
}
288
288
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 ` можно переписать следующим образом:
296
295
297
296
class Complex(real: Double, imaginary: Double) {
298
297
def re = real
0 commit comments