Skip to content

Instantly share code, notes, and snippets.

@FlorianCassayre
Created April 25, 2018 17:17
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 FlorianCassayre/ed4fa5666cc284e027a4d4d6121704e4 to your computer and use it in GitHub Desktop.
Save FlorianCassayre/ed4fa5666cc284e027a4d4d6121704e4 to your computer and use it in GitHub Desktop.
Soit f(_) une fonction...
val f: Double => Double = x => x * x // Une fonction, peu importe
println(f(_)) // Il s'agit bien d'une fonction (anonyme)
val g: Double => Double = f(_) // On peut vérifier qu'elle typecheck
// On peut lui appliquer des valeurs normalement (ne pas oublier les parenthèses !)
println((f(_))(3)) // Affiche 9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment