scala中的if else为表达式,表达式就会有值

var x= 10
if(x>=0){
scala.math.sqrt(x)
}else{
throw new IllegalArgumentException("the value should not be negative")
}
if else表达式的值为res1: Double = 3.1622776601683795
posted @ 2017-05-26 21:57  魅力咔咔  阅读(1648)  评论(0编辑  收藏  举报