문제

Is it possible to extract type parameters in Scala like this:

def some[T <: Either[A, B]](implicit ta: TypeTag[A], tb: TypeTag[B]): T = {
  // A =:= String
  // B =:= Int
  // ...
}

some[Either[String, Int]]()

?

도움이 되었습니까?

해결책

You could rewrite your method like this:

def some[A, B](implicit ta: TypeTag[A], tb: TypeTag[B]): Either[A, B] = ???
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top