```
var max = if (a > b) a else b
```
```
fun getDecsription(color : Color) : String =
when(color){
Blue -> 'cold'
orange -> 'melt'
red -> 'hot'
}
```
check multiple cases.
```
fun getRes(input : String) : String = when(input) {
'yes', 'y' -> 'yes'
'no', 'n' -> 'no'
else -> 'I don't know'
}
```
判断集合也是可以的。
使用is做判断也是可以的。
使用表达式同时吧when里面的参数去掉也是可以的








网友评论