Essentially I want to know if there's any better solution then the following:
t <:< typeOf[Tuple1[_]] ||
t <:< typeOf[Tuple2[_, _]] ||
t <:< typeOf[Tuple3[_, _, _]] ||
t <:< typeOf[Tuple4[_, _, _, _]] ||
t <:< typeOf[Tuple5[_, _, _, _, _]] ||
t <:< typeOf[Tuple6[_, _, _, _, _, _]] ||
t <:< typeOf[Tuple7[_, _, _, _, _, _, _]] ||
t <:< typeOf[Tuple8[_, _, _, _, _, _, _, _]] ||
t <:< typeOf[Tuple9[_, _, _, _, _, _, _, _, _]] ||
t <:< typeOf[Tuple10[_, _, _, _, _, _, _, _, _, _]] ||
t <:< typeOf[Tuple11[_, _, _, _, _, _, _, _, _, _, _]] ||
t <:< typeOf[Tuple12[_, _, _, _, _, _, _, _, _, _, _, _]] ||
t <:< typeOf[Tuple13[_, _, _, _, _, _, _, _, _, _, _, _, _]] ||
t <:< typeOf[Tuple14[_, _, _, _, _, _, _, _, _, _, _, _, _, _]] ||
t <:< typeOf[Tuple15[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _]] ||
t <:< typeOf[Tuple16[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _]] ||
t <:< typeOf[Tuple17[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _]] ||
t <:< typeOf[Tuple18[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _]] ||
t <:< typeOf[Tuple19[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _]] ||
t <:< typeOf[Tuple20[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _]] ||
t <:< typeOf[Tuple21[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _]] ||
t <:< typeOf[Tuple22[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _]]
runtime.ScalaRunTime.isTuple
must be canonical:
def isTuple(x: Any) = x != null && x.getClass.getName.startsWith("scala.Tuple")
ie,
t.typeSymbol.fullName startsWith "scala.Tuple"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.