Created
May 2, 2023 00:21
-
-
Save shvahabi/43f374eca011aeff04d35ecf3507dfcc to your computer and use it in GitHub Desktop.
string interpolation reverse matching
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
| case class Person(name: String, age: Int) | |
| val shahed = """{"name": "Shahed", "age": 42}""" match { case s"""{"name": $name, "age": $age}""" => Person(name, age.toInt) } | |
| // val shahed: Person = Person("Shahed",42) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment