I defined the following function along the lines of Haskell snd
def snd[T](pair: (_, T)): T = pair._2
Trying to use it with a List[ListNode[T]]
doesn't compile. Why not?
list
.reduceOption(snd)
where:
case class ListNode[T](data: T, var next: Option[ListNode[T]])(implicit ordering: Ordering[T]) extends Ordered[ListNode[T]] {...}
Error:
Type mismatch, expected: (NonInferedA1, NonInferedA1) => NonInferedA1, actual Tuple2[_, Nothing] => Nothing