Skip to content

Instantly share code, notes, and snippets.

@retronym
Created October 9, 2010 12:37
Show Gist options
  • Save retronym/618151 to your computer and use it in GitHub Desktop.
Save retronym/618151 to your computer and use it in GitHub Desktop.
scala> def apply[A, B](a: A)(f: A => B) = f(a)
apply: [A,B](a: A)(f: (A) => B)B
scala> apply(1)(_ * 2)
res0: Int = 2
scala> def apply[A, B](a: A, f: A => B) = f(a)
apply: [A,B](a: A,f: (A) => B)B
scala> apply(1, _ * 2)
<console>:7: error: missing parameter type for expanded function ((x$1) => x$1.$times(2))
apply(1, _ * 2)
^
scala> apply(1, (_: Int) * 2)
res2: Int = 2
@kimmikimmi
Copy link

tks! it makes me fully understood!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment