if
val x = 10 if(x>10){ println("x > 10") } else if (x > 5){ println("x > 5") } else { println("else ......") }
if 赋值
scala> val x = 10 x: Int = 10 scala> val y = if(x>0) -x else x y: Int = -10
while & do while
var x = 10
while (x>0){
println("--->: " + x)
x = x - 1
}
var x = 10 do { println("--->: " + x) x = x - 1 } while(x > 0)
---
原文:https://www.cnblogs.com/wooluwalker/p/12297994.html