Skip to content

Instantly share code, notes, and snippets.

@dacr
Last active April 2, 2023 10:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dacr/81dc9cea631bfb48626180dd4734d902 to your computer and use it in GitHub Desktop.
Save dacr/81dc9cea631bfb48626180dd4734d902 to your computer and use it in GitHub Desktop.
scala3 feature examples - indentations / published by https://github.com/dacr/code-examples-manager #d3322b8d-b69c-447f-ab45-abd637e47978/36265a469aeaf4a910edabaa5bd1262cb1fdf5d7
// summary : scala3 feature examples - indentations
// 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 : d3322b8d-b69c-447f-ab45-abd637e47978
// created-on : 2021-04-20T09:43:13+02:00
// managed-by : https://github.com/dacr/code-examples-manager
// run-with : scala-cli $file
//> using scala "3.1.1"
def hello(name:String) =
s"Hello $name"
case class Something(message:String):
def add(x:Int,y:Int):Int =
x+y
def hi(nameOption:Option[String]):Unit =
nameOption match
case None => println("Hi world")
case Some(name) => println(s"Hi $name")
case class Blah(needed:Boolean):
override def toString: String = "BlahBlah"
def truc(blah:Blah):String =
if blah.needed then blah.toString
else "bouhh"
@main def go():Unit =
println(hello("John Doe"))
println(Something("blah").add(40,2))
hi(Some("joe"))
println(truc(Blah(true)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment