Tuple可以作为集合存储不同类型的数据,初始化实例如下: val tuple = (1,3,3.14,"aa") val third = tuple._3 Tuple 下标访问从1开始, 需要用下划线. Scala函数还可以返回Tuple类型的值,并接收,如: val (first,second,third,forth) = tuple 跟Tuple无关但是挺有意思的东西,顺便写在这里: zip方法,(拉链操作) val pa = Array(1,2,3) //&…
Scala's object-oriented collections support mutable and immutable type hierarchies. Also support functional higher-order operations such as map, filter, and reduce that let you use expression-oriented programming in collections. Higher-order operatio…
1. Variables (1) Three ways to define variables: 1) val refers to define an immutable variable; scala> val x = x: Int = scala> x*x res4: Int = scala> res4 + # use result as a value res6: Int = scala> res4 + res6 res7: Int = scala> x = # x i…