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/scala.quoted.runtime/QuoteMatching/ExprMatchModule

ExprMatchModule

scala.quoted.runtime.QuoteMatching.ExprMatchModule

Attributes

Source
QuoteMatching.scala
Graph
Supertypes
classObject
traitMatchable
classAny
Self type
QuoteMatching.this.ExprMatch.type

Members list

Value members

Abstract methods

defunapply[TypeBindings,Tup <:Tuple](scrutinee:Expr[Any])(usingpattern:Expr[Any]):Option[Tup]

Pattern matches an the scrutineeExpr against the patternExpr and returns a tuple with the matched holes if successful.

Pattern matches an the scrutineeExpr against the patternExpr and returns a tuple with the matched holes if successful.

Examples:

  • ExprMatch.unapply('{ f(0, myInt) })('{ f(0, myInt) }, _) will returnSome(()) (where() is a tuple of arity 0)
  • ExprMatch.unapply('{ f(0, myInt) })('{ f(patternHole[Int], patternHole[Int]) }, _) will returnSome(Tuple2('{0}, '{ myInt }))
  • ExprMatch.unapply('{ f(0, "abc") })('{ f(0, patternHole[Int]) }, _) will returnNone due to the mismatch of types in the hole

Holes:

  • scala.quoted.runtime.Patterns.patternHole[T]: hole that matches an expressionx of typeExpr[U] ifU <:< T and returnsx as part of the match.

Value parameters

pattern

Expr[Any] containing the pattern tree

scrutinee

Expr[Any] on which we are pattern matching

Attributes

Returns

None if it did not match,Some(tup) if it matched wheretup contains `Expr[Ti]``

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

[8]ページ先頭

©2009-2025 Movatter.jp