scala教程 – spark应用之scala语言编程入门(一)
安装scala
https://downloads.lightbend.com/scala/2.12.5/scala-2.12.5.msi
windwos cmd
输入scala
C:\Users\yang>scala
Welcome to Scala 2.12.5 (Java HotSpot(TM) Client VM, Java 1.8.0_144).
Type in expressions for evaluation. Or try :help.
scala>
进入命令行
scala> var f1 = (arg: Int) => arg + 3
f1: Int => Int = $$Lambda$1047/10935329@71d261
scala> f1
res0: Int => Int = $$Lambda$1047/10935329@71d261
scala> var array = Array(1,2,3,4,5)
array: Array[Int] = Array(1, 2, 3, 4, 5)
scala> array.map(f1)
res1: Array[Int] = Array(4, 5, 6, 7, 8)
scala> array.map((arg: Int) => arg + 3)
res0: Array[Int] = Array(4, 5, 6, 7, 8)
scala> array.map(_+3) //占位符
res1: Array[Int] = Array(4, 5, 6, 7, 8)
参考:
https://www.scala-lang.org/download/