If Statements

If statements function slightly differently to languages like Java, think of them more like a method themselves as they return a value.

// Java.
String someValue = null;
if (1 == 1) {
  someValue = "1 is definitely 1.";
} else {
  someValue = "Maths is broken, the end is nigh.";
}
// Scala.
val someValue: String = if (1 == 1) {
  "1 is definitely 1."
} else {
  "Maths is broken, the end is nigh."
}