摘要: var x= 10if(x>=0){ scala.math.sqrt(x)}else{ throw new IllegalArgumentException("the value should not be negative")}if else表达式的值为res1: Double = 3.16227 阅读全文
posted @ 2017-05-26 21:57 魅力咔咔 阅读(1648) 评论(0) 推荐(0) 编辑
摘要: var list=List("Mary","Tom","Mike")println("***********for 第一种写法************")for(s <-list) println(s)println("***********for 第二种写法************")for{ s 阅读全文
posted @ 2017-05-26 21:22 魅力咔咔 阅读(372) 评论(0) 推荐(0) 编辑
摘要: def sum(args: Int*) = {var result=0for(arg <- args) result+=arg result}sum(1,2,3) 阅读全文
posted @ 2017-05-26 21:19 魅力咔咔 阅读(1796) 评论(0) 推荐(0) 编辑