Varargs
extends Object with SerializableLiteral sequence of expressions
Supertypes
Object, SerializableMembers
def
apply
[T] ( xs: Seq[Expr[T]] ) ( implicit tp: Type[T] , qctx: QuoteContext ) : Expr[Seq[T]]Lifts this sequence of expressions into an expression of a sequence
Transforms a sequence of expression
Seq(e1, e2, ...)
where ei: Expr[T]
to an expressi...
Lifts this sequence of expressions into an expression of a sequence
Transforms a sequence of expression
Seq(e1, e2, ...)
where ei: Expr[T]
to an expression equivalent to
'{ Seq($e1, $e2, ...) }
typed as an Expr[Seq[T]]
Usage:
'{ List(${Varargs(List(1, 2, 3))}: _*) } // equvalent to '{ List(1, 2, 3) }
def
unapply
[T] ( expr: Expr[Seq[T]] ) ( implicit qctx: QuoteContext ) : Option[Seq[Expr[T]]]Matches a literal sequence of expressions and return a sequence of expressions.
Usage:
Matches a literal sequence of expressions and return a sequence of expressions.
Usage:
inline def sum(args: Int*): Int = ${ sumExpr('args) }
def sumExpr(argsExpr: Expr[Seq[Int]])(using QuoteContext): Expr[Int] = argsExpr match
case Varargs(argVarargs) =>
// argVarargs: Seq[Expr[Int]]
...
}