using scala wart I get:
def lastWithRecursion(input: Seq[Int]): Try[Int] = input match {
case head :: Nil => Success(head)
case _ :: tail => lastWithRecursion(tail)
case _ => Failure(new NoSuchElementException("No such element")) // how to avoid inferred type containing nothing.
}
how to avoid inferred type containing nothing
?
Try with added generic to Failure
:
def lastWithRecursion(input: Seq[Int]): Try[Int] = input match {
case head :: Nil => Success(head)
case _ :: tail => lastWithRecursion(tail)
case _ => Failure[Int](new NoSuchElementException("No such element")) // how to avoid inferred type containing nothing.
}