This works:
List(3, 1, 2).sorted apply 1
res1: Int = 2
And this works:
var x = List(3, 1, 2).sorted
x: List[Int] = List(1, 2, 3)
x(1)
res2: Int = 2
but this doesn’t:
List(3, 1, 2).sorted (1)
error: type mismatch;
found : Int(1)
required: Ordering[?]
List(3, 1, 2).sorted (1)
^
And even parentheses don’t clue the parser in to what I want:
(List(3, 1, 2).sorted)(1)
error: type mismatch;
found : Int(1)
required: Ordering[?]
(List(3, 1, 2).sorted)(1)
It seems like a natural expression. What am I doing wrong?
This works:
(Listed(3, 1, 2).sorted _)(1),but I’m not sure whether it is much more convenient to use than:
Listed(3, 1, 2).sorted apply 1.I’d go for the latter anyways.