It works as expected.
This line:
List(1,2,3) map {x=>x*2}.filter((x:Int)=>x==2)
means
List(1,2,3) map ( {x=>x*2}.filter((x:Int)=>x==2) )
It is definitely a error, but you could use it like this:
val f1 = (x: Int) => x * 2
val f2 = (x: Int) => x + 2
List(1,2,3) map f1.andThen(f2) // List(1,2,3).map( f1.andThen(f2) )
//List[Int] = List(4, 6, 8)
This code creates new function as composition of 2 functions: {(x: Int)=>x*2}.andThen((x:Int)=> x + 2)
and then applies map
method to it.
You could mix Space or Dot notations, but you should know that "priority" of dot is higher.