Skip to content

Commit f749e02

Browse files
translate tour/automatic-closures into Japanese
1 parent 9a9b968 commit f749e02

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

_ja/tour/automatic-closures.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
---
22
layout: tour
3-
title: Automatic Type-Dependent Closure Construction
3+
title: 型依存クロージャの自動構築
44
language: ja
55

66
discourse: true
77

88
partof: scala-tour
99
---
1010

11-
Scala allows parameterless function names as parameters of methods. When such a method is called, the actual parameters for parameterless function names are not evaluated and a nullary function is passed instead which encapsulates the computation of the corresponding parameter (so-called *call-by-name* evaluation).
11+
Scalaはメソッドのパラメータにパラメータを受け取らない関数名が使えます。このようなメソッドが呼び出される時、パラメータを受け取らない関数名は実際に評価されず、代わりに対応するパラメーターの処理をカプセル化した、引数を取らない関数が渡されます(そのため *名前渡し*評価と呼ばれます)。
1212

13-
The following code demonstrates this mechanism:
13+
以下のコードはこの仕組みを説明しています。
1414

1515
object TargetTest1 extends Application {
1616
def whileLoop(cond: => Boolean)(body: => Unit): Unit =
@@ -25,11 +25,11 @@ The following code demonstrates this mechanism:
2525
}
2626
}
2727

28-
The function whileLoop takes two parameters `cond` and `body`. When the function is applied, the actual parameters do not get evaluated. But whenever the formal parameters are used in the body of `whileLoop`, the implicitly created nullary functions will be evaluated instead. Thus, our method `whileLoop` implements a Java-like while-loop with a recursive implementation scheme.
28+
関数 whileLoop は2つのパラメータ`cond``body`を受け取ります。関数が適用される時、実際のパラメータは評価されません。しかし形式上のパラメータが`whileLoop`の本体内で使われる度に、暗黙に生成された引数の無い関数が代わりに評価されます。このようにメソッド`whileLoop`はJavaのようなwhileループを再帰的な実装案で実装しています。
2929

30-
We can combine the use of [infix/postfix operators](operators.html) with this mechanism to create more complex statements (with a nice syntax).
30+
[中置/後置 演算子](operators.html)とこのメカニズムを組み合わせ利用し、より複雑な式を(より良い構文で)が作れます。
3131

32-
Here is the implementation of a loop-unless statement:
32+
こちらがloop-unless式の実装です。
3333

3434
object TargetTest2 extends Application {
3535
def loop(body: => Unit): LoopUnlessCond =
@@ -46,9 +46,9 @@ Here is the implementation of a loop-unless statement:
4646
i -= 1
4747
} unless (i == 0)
4848
}
49-
The `loop` function just accepts a body of a loop and returns an instance of class `LoopUnlessCond` (which encapsulates this body object). Note that the body didn't get evaluated yet. Class `LoopUnlessCond` has a method `unless` which we can use as a *infix operator*. This way, we achieve a quite natural syntax for our new loop: `loop { < stats > } unless ( < cond > )`.
49+
この`loop`関数はループ処理の本体を受け取り、クラス`LoopUnlessCond`(bodyのオブジェクトをカプセル化する)のインスタンスを返すだけです。bodyはまだ評価されていないことに気をつけてください。クラス`LoopUnlessCond`は中置演算子として使えるメソッド`unless`を持ちます。このようにより自然な構文で新しいループ処理`loop { < stats > } unless ( < cond > )`を作れます。
5050

51-
Here's the output when `TargetTest2` gets executed:
51+
こちらが`TargetTest2`を実行した時の出力です。
5252

5353
i = 10
5454
i = 9

0 commit comments

Comments
 (0)