Last active
May 25, 2024 10:19
-
-
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/c83017ae900854fc748339c5b7cdc7ea8edfdd6d
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 - 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.4.2" | |
@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