Varargs
object Varargs
Expression representation of literal sequence of expressions.
Varargs
can be used to create the an expression args
that will be used as varargs '{ f($args: _*) }
or it can be used to extract all the arguments of the a varargs.
- Source:
- Varargs.scala
Value members
Concrete methods
Lifts this sequence of expressions into an expression of a sequence
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))}: _*) } // equivalent to '{ List(1, 2, 3) }
- Source:
- Varargs.scala
Matches a literal sequence of expressions and return a sequence of expressions.
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 Quotes): Expr[Int] = argsExpr match
case Varargs(argVarargs) =>
// argVarargs: Seq[Expr[Int]]
...
}
- Source:
- Varargs.scala