Last active
February 3, 2026 20:21
-
-
Save dacr/72299ae1161a756e64fb564433103388 to your computer and use it in GitHub Desktop.
scala3 feature examples - vararg splices / published by https://github.com/dacr/code-examples-manager #7cac8692-379b-42a4-841e-07d8800e28e6/f0119c4255e4f453f0b4c4cbcc821731a492f22f
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
| // summary : scala3 feature examples - vararg splices | |
| // keywords : scala3, tutorial, @testable | |
| // publish : gist | |
| // authors : David Crosson | |
| // license : Apache License Version 2.0 (https://www.apache.org/licenses/LICENSE-2.0.txt) | |
| // id : 7cac8692-379b-42a4-841e-07d8800e28e6 | |
| // created-on : 2021-04-20T10:55:53+02:00 | |
| // managed-by : https://github.com/dacr/code-examples-manager | |
| // run-with : scala-cli $file | |
| //> using scala "3.4.2" | |
| @main def go() = { | |
| val arr = Array(1,2,3,4,5) | |
| val lst = List(arr*) | |
| lst match { | |
| case List(1,2,xs*) => println(xs) | |
| case List(2,_*) => println("other") | |
| case _ => println("unsupported") | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment