/ / Scala Tuple10 implicitné objednávanie nefunguje - scala, implicitne

Scala Tuple10 implicitné usporiadanie nefunguje - scala, implicitné

Môžem získať porovnanie metódy práce až Tuple9 ako nasledujúce:

  import scala.math.Ordered.orderingToOrdered
(1,2,"ab",4,5,6.0,7l,"de",1.0) compare (1,2,"ab",4,5,6.0,7l,"de",1.0)

Ale s Tuple10 dostanem chybu kompilácie:

  import scala.math.Ordered.orderingToOrdered
(1,2,"ab",4,5,6.0,7l,"de",1.0,2) compare (1,2,"ab",4,5,6.0,7l,"de",1.0,2) // >> compile error: value compare is not a member of (Int, Int, String, Int, Int, Double, Long, String, Double, Int)

Snažil som sa striedavo, ale to tiež dáva implicitnú chybu:

implicitly[Ordering[Tuple10[Int, Int, String, Int, Int, Double, Long, String, Double, Double]]].compare((1,2,"ab",4,5,6.0,7l,"de",1.0,4), (1,2,"ab",4,5,6.0,7l,"de",1.0,4))

compiler error:
No implicit Ordering defined for (Int, Int, String, Int, Int, Double, Long, String, Double, Double).
not enough arguments for method implicitly: (implicit e: Ordering[(Int, Int, String, Int, Int, Double, Long, String, Double, Double)])Ordering[(Int, Int, String, Int, Int, Double, Long, String, Double, Double)]. Unspecified value parameter e.

Vyzerá to, že Objednávanie je definované len pre Tuple9. Opravte ma, ak sa mýlim.

odpovede:

2 pre odpoveď č. 1

Ako môžete vidieť z zdrojový kód, máte pravdu, ide len do Tuple9. Ale potom, čo ste videli vzor v každej iterácii, mali by ste byť schopní kopírovať a rozširovať ho podľa potreby.