scala> val alist = List(1,2,3,4,5)
alist: List[Int] = List(1, 2, 3, 4, 5)
scala> alist filter { 2.< }
res2: List[Int] = List(3, 4, 5)
scala> alist filter { 2 < }
res3: List[Int] = List(3, 4, 5)
scala> alist filter { > 3 }
<console>:1: error: ';' expected but integer literal found.
alist filter { > 3 }
Why would { 2.< }
and {2 <}
work? I think at least I should write { 2 < _ }
right?
A method that requires no arguments, you can alternatively leave off the dot and use postfix operator notation:
scala> val s = "Hello, world!"
s: java.lang.String = Hello, world!
scala> s toLowerCase
res4: java.lang.String = hello, world!
But here, <
method is not those kinds of methods which requires no arguments right?
Can you point me what is this usage?