标签:
val map = Map("book" -> 10, "gun" -> 18, "ipad" -> 100)
for ((k, v) <- map) yield (k, v * 0.9)
|
val scores = scala.collection.mutable.Map("Scala" -> 7, "Hadoop" -> 8, "Spark" -> 10)
val hadoopScore = scores.getOrElse("Hadoop", 0)
scores += ("R" -> 9)
scores -= "Hadoop"
|
val sortedScore = scala.collection.immutable.SortedMap( "Scala" ->7 ,"Hadoop" -> 8, "Spark" ->10 )
|
val tuple = (1,2,3.14,"Rocky" , "Spark")
val third = tuple._3
val (first,second, thirda, fourth , fifth) = tuple
val(f,s,_ ,_,_ ) = tuple
|
val symbols = Array("[","-","]")
val counts = Array(2,5,2)
val pairs = symbols.zip(counts)
for( (x,y) <- pairs) print(x*y)
|
Scala 深入浅出实战经典(1-64讲)完整视频、PPT、代码下载:
百度云盘:http://pan.baidu.com/s/1c0noOt6
腾讯微云:http://url.cn/TnGbdC
360云盘:http://yunpan.cn/cQ4c2UALDjSKy 访问密码 45e2
标签:
原文地址:http://www.cnblogs.com/wangshuo1/p/4694762.html