「Example4.3」の編集履歴(バックアップ)一覧はこちら
Example4.3 - (2011/02/24 (木) 08:30:54) の1つ前との変更点
追加された行は緑色になります。
削除された行は赤色になります。
#co(){
4.3 Conditional Expressions
Scala's if-else lets one choose between two alternatives. Its syntax is like Java's if-else. But where Java's if-else can be used only as an alternative of statements, Scala allows the same syntax to choose between two expressions. That's why Scala's if-else serves also as a substitute for Java's conditional expression ... ? ... : ....
}
** 4.3 条件式
Scala の if-else は2つの選択肢から1つを選びます。構文は Java の if-else と似ています。しかし Java の if-else が文の選択にしか使えないのに対し、Scala は同じ構文を、2つの式の選択にも使えます。ですから Scala の if-else は Java の条件演算子 ... ? ... : ... の代わりに使えます。
&b(){Example 4.3.1 }
scala> def abs(x: Double) = if (x >= 0) x else -x
abs: (Double)Double
#co(){
Scala's boolean expressions are similar to Java's; they are formed from the constants true and false, comparison operators, boolean negation ! and the boolean operators && and ||.
}
Scala のブール式は Java のものと似ています。定数 true と false、比較演算子、ブール値の否定 !、ブール値の演算子 && と || から構成されています。
#center(){[[前ページ>Example4.2]] [[ 4 章>ExampleChap4]] [[目次>ScalaByExample和訳]] [[次ページ>Example4.4]]}
----
#comment
d#co(){
4.3 Conditional Expressions
Scala's if-else lets one choose between two alternatives. Its syntax is like Java's if-else. But where Java's if-else can be used only as an alternative of statements, Scala allows the same syntax to choose between two expressions. That's why Scala's if-else serves also as a substitute for Java's conditional expression ... ? ... : ....
}
#setmenu2(ex-r-menu)
** 4.3 条件式
Scala の if-else は2つの選択肢から1つを選びます。構文は Java の if-else と似ています。しかし Java の if-else が文の選択にしか使えないのに対し、Scala は同じ構文を、2つの式の選択にも使えます。ですから Scala の if-else は Java の条件演算子 ... ? ... : ... の代わりに使えます。
&b(){Example 4.3.1 }
scala> def abs(x: Double) = if (x >= 0) x else -x
abs: (Double)Double
#co(){
Scala's boolean expressions are similar to Java's; they are formed from the constants true and false, comparison operators, boolean negation ! and the boolean operators && and ||.
}
Scala のブール式は Java のものと似ています。定数 true と false、比較演算子、ブール値の否定 !、ブール値の演算子 && と || から構成されています。
#center(){[[前ページ>Example4.2]] [[ 4 章>ExampleChap4]] [[目次>ScalaByExample和訳]] [[次ページ>Example4.4]]}
----
#comment