Movatterモバイル変換


[0]ホーム

URL:


Scala 3
3.7.4
LearnInstallPlaygroundFind A LibraryCommunityBlog
Scala 3
LearnInstallPlaygroundFind A LibraryCommunityBlog
DocsAPI
Generated with
Copyright (c) 2002-2025, LAMP/EPFL
Copyright (c) 2002-2025, LAMP/EPFL
Scala 3/scala/scala.quoted/Varargs

Varargs

scala.quoted.Varargs
objectVarargs

Expression representation of literal sequence of expressions.

Varargs can be used to create the an expressionargs that will be used as varargs'{ f($args: _*) } or it can be used to extract all the arguments of the a varargs.

Attributes

Source
Varargs.scala
Graph
Supertypes
classObject
traitMatchable
classAny
Self type
Varargs.type

Members list

Value members

Concrete methods

defapply[T](xs:Seq[Expr[T]])(usingType[T])(usingQuotes):Expr[Seq[T]]

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 expressionSeq(e1, e2, ...) whereei: Expr[T] to an expression equivalent to'{ Seq($e1, $e2, ...) } typed as anExpr[Seq[T]]

Usage:

def f(using Quotes) = {  import quotes.reflect.*'{ List(${Varargs(List('{1}, '{2}, '{3}))}: _*) } // equivalent to '{ List(1, 2, 3) }}

Attributes

Source
Varargs.scala
defunapply[T](expr:Expr[Seq[T]])(usingQuotes):Option[Seq[Expr[T]]]

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]]

Attributes

Source
Varargs.scala
In this article
Generated with
Copyright (c) 2002-2025, LAMP/EPFL
Copyright (c) 2002-2025, LAMP/EPFL

[8]ページ先頭

©2009-2025 Movatter.jp