scala> val someNumbers = List(-11,2,-12,8,9)
scala> someNumbers.filter( x=>x<8 )
scala> someNumbers.filter(_>0)
scala> val f= (_: Int)+(_: Int)
scala> someNumbers.foreach(println _)
equals
someNumbers.foreach(x => println(x))
2. closure
2. closure
def makeIncreaser(more: Int) = (x: Int) => x + more
3.
scala> def twice(op: Double => Double, x: Double) = op(op(x))
scala> twice(_ + 1, 5)
4.
In Scala it is forbidden to define a field and method with the same name in the same class, whereas this is
allowed in Java.
Generally, Scala has just two namespaces for definitions in place of Java's four. Java's four namespaces
are fields, methods, types, and packages. By contrast, Scala's two namespaces are:
• values (fields, methods, packages, and singleton objects)
• types (class and trait names)