演示了值函数,匿名函数,闭包。。。
其它具体的应用,还得在生产当中吧。。
这个告一段落。。其它SAM,CURRY,高阶函数,集合,泛型,隐式类。。这些,还是找专门的书去深入了解啦。。。
C:\Users\hengheng>scalaWelcome to Scala version 2.11.6 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_43).Type in expressions to have them evaluated.Type :help for more information.scala> def add(x : Int, y : Int) : Int = (x + y)add: (x: Int, y: Int)Intscala> var result = add _result: (Int, Int) => Int =scala> result(1, 2)res0: Int = 3scala> (x : Int) => x + 3res1: Int => Int = scala> var fun = (x : Int) => x + 3fun: Int => Int = scala> fun(7)res2: Int = 10scala> var y = 1y: Int = 1scala> val sum = (x : Int) => x + ysum: Int => Int = scala> sum(5)res3: Int = 6scala>