Skip to content

Instantly share code, notes, and snippets.

@dacr
Last active May 25, 2024 10:19
Show Gist options
  • Save dacr/9e3cf058e18df32709a210de05c20111 to your computer and use it in GitHub Desktop.
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/ae1a7e43a8d5f33a7b91a6cee395bc55afdbeb02
// summary : scala3 feature examples - main functions with basic arguments parsing
// keywords : scala3, tutorial, @testable
// publish : gist
// authors : David Crosson
// license : Apache NON-AI License Version 2.0 (https://raw.githubusercontent.com/non-ai-licenses/non-ai-licenses/main/NON-AI-APACHE2)
// 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