Last active
February 3, 2026 20:21
-
-
Save dacr/9e3cf058e18df32709a210de05c20111 to your computer and use it in GitHub Desktop.
scala3 feature examples - main functions with basic arguments parsing / published by https://github.com/dacr/code-examples-manager #b8e766f8-6641-429e-8f12-cc1e59522253/bfeca9d2409f6b902c08580c8583ebe34742a638
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 - main functions with basic arguments parsing | |
| // 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 : b8e766f8-6641-429e-8f12-cc1e59522253 | |
| // created-on : 2021-05-07T07:22:11+02:00 | |
| // managed-by : https://github.com/dacr/code-examples-manager | |
| // run-with : scala-cli $file -- arg1 arg2 arg3 | |
| //> using scala "3.4.2" | |
| //@main | |
| def go1() = { | |
| println(s"Hello world !") | |
| } | |
| @main | |
| def go2(args:String*) = { | |
| println("args="+args.mkString(",")) | |
| } | |
| //@main | |
| def go2(name:String, age:Int, alive:Boolean, remains:String*) = { | |
| println(s"hello $name $age $alive"+remains.mkString(" (",",",")")) | |
| } | |
| // scala-cli scala3-feature-main.scala -- david 42 true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment