Skip to content

Instantly share code, notes, and snippets.

@dacr
Last active February 3, 2026 20:19
Show Gist options
  • Select an option

  • Save dacr/0fa24d015c207fdc5e267c9acdd31363 to your computer and use it in GitHub Desktop.

Select an option

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/91ac201e7ddc771617808d1f7e803528318e165f
// summary : scala3 feature examples - parameter untupling
// keywords : scala3, tutorial, @testable
// publish : gist
// authors : David Crosson
// license : Apache License Version 2.0 (https://www.apache.org/licenses/LICENSE-2.0.txt)
// 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