1
Seq(1, 2, 3).reduce(math.max)  // ok: gives 3
Seq[Long](1, 2, 3).reduce(math.max) // error: type mismatched
                          ^^^^^^^^

Why it cannot deduce the Long version of math.max?

Seq[Long](1, 2, 3).reduce(math.max(_:Long, _:Long)) // ok: gives 3L
                          ^^^^^^^^^^^^^^^^^^^^^^^^

Above can solve the problem, but is there any short/clean way to tell the compiler to select Long version of math.max?

duplode
  • 33,731
  • 7
  • 79
  • 150
cinsk
  • 1,576
  • 2
  • 12
  • 14

0 Answers0