Skip to content

Instantly share code, notes, and snippets.

@dorsev
Created November 3, 2018 21:59
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 dorsev/c0f4e372d4d209473b3f6e538e1a4a7e to your computer and use it in GitHub Desktop.
Save dorsev/c0f4e372d4d209473b3f6e538e1a4a7e to your computer and use it in GitHub Desktop.
Eta Expansion in scala - p2
scala> val etaexplained = emphasisFunc _
etaexplained: String => String = $$Lambda$1239/712726821@5a5b394
//what happens on multiple paramters list ?
//they get curried away.
//for example
scala> def strAddByNumAndMultiplty(str:String)(numToAdd:Int)(numToMultiply:Int) = str.toInt + numToAdd * numToMultiply
strAddByNumAndMultiplty: (str: String)(numToAdd: Int)(numToMultiply: Int)Int
scala> strAddByNumAndMultiplty _
res5: String => (Int => (Int => Int)) = $$Lambda$1286/1637214165@f2120d5
scala> strAddByNumAndMultiplty _
res5: String => (Int => (Int => Int)) = $$Lambda$1286/1637214165@f2120d5
scala> val func = strAddByNumAndMultiplty _
func: String => (Int => (Int => Int)) = $$Lambda$1287/795982694@4d8e6daa
scala> func("1")(2)(3)
res6: Int = 7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment