Blocks

Blocks are one or more expressions grouped together with curly braces. Each expression is evaluated in order and the value of the last expression is returned.

ブロックは、波括弧でグループ化された 1 つ以上の式です。各式は順番に評価され、最後の式の値が返されます。

Any variables assigned within the block can only be used within the block.

ブロック内で割り当てられた変数は、ブロック内でのみ使用できます。

Try uncommenting io.debug(degrees) to see the compile error from trying to use a variable that is not in scope.

スコープにない変数を使おうとしたときのコンパイルエラーを確認するために io.debug(degrees) をアンコメントしてみてください。

Blocks can also be used to change the order of evaluation of binary operators expressions.

ブロックは、二項演算子式の評価順序を変更するためにも使用できます。

* binds more tightly than + so the expression 1 + 2 * 3 evaluates to 7. If the 1 + 2 should be evaluated first to make the expression evaluate to 9 then the expression can be wrapped in a block: { 1 + 2 } * 3. This is similar to grouping with parentheses in some other languages.

*+ よりも強く結合するので、式 1 + 2 * 3 の評価結果は 7 になります。もし式の結果を 9 に評価するために 1 + 2 を先に評価する必要がある場合は、{ 1 + 2 } * 3 のように式をブロックで囲むことができます。これはいくつかの他の言語における、丸括弧によるグループ化と似ています。