18446744073709551615
18446744073709551615

Reputation: 16842

scala: Ordering.by vs Ordering.on

What is the difference between Ordering.by() and Ordering.on() in Scala?

(Well, one is defined in the trait and the other in the companion object, and the implementation code is also different, but there must be a reason why the language needs both.)

Upvotes: 0

Views: 153

Answers (1)

Gaël J
Gaël J

Reputation: 15220

From the documentation of Ordering.by:

This function is an analogue to Ordering.on where the Ordering[S] parameter is passed implicitly.

Basically the two are the same, it's just a matter of convenience depending of what is your context and what you're working with.

Upvotes: 3

Related Questions