You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
let('{1}) // will return a `Expr[Any]` that contains an `Expr[Int]]`
505
505
```
506
506
507
+
It is also possible to refer to the same type variable multiple times in a pattern.
508
+
509
+
```scala
510
+
case'{ $x: (t, t) } =>
511
+
```
512
+
507
513
While we can define the type variable in the middle of the pattern, their normal form is to define them as a `type` with a lower case name at the start of the pattern.
508
-
We use the Scala backquote `` `t` `` naming convention which interprets the string within the backquote as a literal name identifier.
509
-
This is typically used when we have names that contain special characters that are not allowed for normal Scala identifiers.
510
-
But we use it to explicitly state that this is a reference to that name and not the introduction of a new variable.
514
+
511
515
```scala
512
-
case'{ typet; $x: `t` } =>
516
+
case'{ typet; $x: t } =>
513
517
```
514
-
This is a bit more verbose but has some expressivity advantages such as allowing to define bounds on the variables and be able to refer to them several times in any scope of the pattern.
518
+
519
+
This is a bit more verbose but has some expressivity advantages such as allowing to define bounds on the variables.
0 commit comments