Scala Tutorialsを読む 20 If
http://scalatutorials.com/tour/interactive_tour_of_scala_if.html
20 If
Conditions are almost the same as in imperative languages such as Java or C.
条件はほぼ、命令的な言語のJavaやCと同じです。
However one important thing to remember in Scala, is that everything is an expression, even an if block. しかしながらScalaではifブロックはすべて式であるという1つ重要な点を覚えてください。
The ternary operator ( condition _ truePart : falsePart
) in Scala is simply if (condition) truePart else falsePart
Scalaの3項演算子( condition _ truePart : falsePart
)は単に
if (condition) truePart else falsePart
です。