the Scala Language. • 2: Working with Data: Literals, Values, Variables, and Types. • 3: Expressions and Conditionals. • 4: Functions • 5: First-Class Functions.
12180 x: Int = 12180 scala> val y:Any = x y: Any = 12180 scala> y match { | case x: String => s"'x'" | case x: Double => f"$x%.2f" | case x: Float => s"$x%.2f" | case x: Long => s"${x}l" | case x: Int => s"${x}i" | } res0: String = 12180i
a identity: (a: Any)Any scala> val s:String = identity("Hello") <console>:11: error: type mismatch; found : Any required: String val s:String = identity("Hello") ^
double(x: Int): Int = x * 2 double: (x: Int)Int scala> double(5) res3: Int = 10 scala> val myDouble: (Int) => Int = double myDouble: Int => Int = <function1> scala> myDouble(10) res4: Int = 20