list的下标访问
var t = List(1,2,3,5,5) println(t(2))
map函数
println(t.map(a=> {print("***"+a); a+2}));
添加元素
var t2 = t.+:("test") println(6::t2)
foreach
t2.foreach(t=>print(t))
去重
t.distinct
累加
println(t./:(100)({ (sum,num)=>print(sum+"--"+num+" "); sum-num }));
reduce
println(t.reduce(_-_))
元组:
var tuple01 = (1,5,6,6); println(tuple01._1) println(tuple01._4)
map:
var m1 = Map[String,Int](("a" , 1), ("b" , 2)); println(m1("a")); m1 += ("c" -> 3); println(m1) m1.foreach(a=>{ println(a+" "+a._1+" "+a._2) }); m1.keys.foreach(b=>println(m1(b) = 2)); println(m1)