lundi 9 novembre 2020

How to extract types from tuple type?

I have a code

case class MyTypeTag[T] () 

def getTypeTags[TT <: Product : TypeTag] = {
  val subtypesTags: List[MyTypeTag[Option[_]] = ???  
  sybtypesTags
}

val res = getTypeTags[(Int, String, Boolean)] 
// res = MyTypeTag[Option[Int]] :: MyTypeTag[Option[String]] :: MyTypeTag[Option[Boolean]] :: Nil

so i want to call function getTypeTags passing any tuple type as type parameter and get list of MyTypeTag instances with each type inside tuple wrapped in Option

if in intelliJ i evaluate expression typeof[TT] i see property args with list of my types, but i do not know how to access from code. Or may be some other ways can be apllied.

Thanks in advance





Aucun commentaire:

Enregistrer un commentaire