Last active
October 5, 2023 05:29
-
-
Save xuwei-k/0d620c6ab8e1a44a9d3e4770b9ebc46c to your computer and use it in GitHub Desktop.
scala xml pattern match
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Welcome to Scala 2.12.18 (OpenJDK 64-Bit Server VM, Java 11.0.20). | |
Type in expressions for evaluation. Or try :help. | |
scala> val <a>{ b }</a> = <a></a> | |
scala.MatchError: <a></a> (of class scala.xml.Elem) | |
... 55 elided | |
scala> val <a>{ _ }</a> = <a>c</a> | |
scala> val <a>{ _* }</a> = <a>c</a> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Welcome to Scala 2.13.12 (OpenJDK 64-Bit Server VM, Java 11.0.20). | |
Type in expressions for evaluation. Or try :help. | |
scala> val <a>{ b }</a> = <a></a> | |
scala.MatchError: <a></a> (of class scala.xml.Elem) | |
... 59 elided | |
scala> val <a>{ _ }</a> = <a>c</a> | |
scala> val <a>{ _* }</a> = <a>c</a> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Welcome to Scala 3.3.1 (11.0.20, Java OpenJDK 64-Bit Server VM). | |
Type in expressions for evaluation. Or try :help. | |
scala> val <a>{ b }</a> = <a></a> | |
1 warning found | |
-- Warning: -------------------------------------------------------------------- | |
1 |val <a>{ b }</a> = <a></a> | |
| ^^^^^^^^^^^^^^^^^^^^^ | |
|pattern binding uses refutable extractor `_root_.scala.xml.Elem` | |
| | |
|If this usage is intentional, this can be communicated by adding `: @unchecked` after the expression, | |
|which may result in a MatchError at runtime. | |
scala.MatchError: <a></a> (of class scala.xml.Elem) | |
... 66 elided | |
scala> val <a>{ _ }</a> = <a>c</a> | |
1 warning found | |
-- Warning: -------------------------------------------------------------------- | |
1 |val <a>{ _ }</a> = <a>c</a> | |
| ^^^^^^^^^^^^^^^^^^^^^^ | |
|pattern binding uses refutable extractor `_root_.scala.xml.Elem` | |
| | |
|If this usage is intentional, this can be communicated by adding `: @unchecked` after the expression, | |
|which may result in a MatchError at runtime. | |
scala> val <a>{ _* }</a> = <a>c</a> | |
-- [E032] Syntax Error: -------------------------------------------------------- | |
1 |val <a>{ _* }</a> = <a>c</a> | |
| ^ | |
| pattern expected | |
| | |
| longer explanation available when compiling with `-explain` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment