Scala Tutorialsを読む 20 If

20 If

Conditions are almost the same as in imperative languages such as Java or 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です。