Last active
April 2, 2023 10:11
-
-
Save dacr/0fa24d015c207fdc5e267c9acdd31363 to your computer and use it in GitHub Desktop.
scala3 feature examples - parameter untupling / published by https://github.com/dacr/code-examples-manager #ead4dec5-9891-4343-9aa9-e389ca582f2b/363ac35e2045a4645932c4e4c02105816345406c
This file contains 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 - parameter untupling | |
// 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 : ead4dec5-9891-4343-9aa9-e389ca582f2b | |
// created-on : 2021-04-20T10:22:53+02:00 | |
// managed-by : https://github.com/dacr/code-examples-manager | |
// run-with : scala-cli $file | |
//> using scala "3.1.3" | |
@main def go() = { | |
val xs = List( 1->2, 3->4, 5->6) | |
xs.map{case (x,y) => x+y} // classic but the case syntax suggest that it can fail | |
xs.map((x,y) => x+y) // better syntax provided by scala 3, it clearly say that it can't fail | |
xs.map(_ + _) // Cool... | |
println("...raoul") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment