Last active
May 25, 2024 10:18
-
-
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/627675e12884d1e7701c1a2171b4f447216ca646
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 - 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.4.2" | |
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