Wednesday 4 November 2015

Methods with Multiple Argument List


def draw(offset: Point= Point(0.0,0.0))(f: String=>Unit): Unit

You can have as many argument lists as you want, but it's rare to use more than two.

1. Multiple lists promote a very nice block structure syntax when the last argument list
takes a single function.

2. Type inference in the subsequent argument lists.
def m[A](a:A)(f:A=>String) = f(a)
m(100)(i => s"$i + $i")

3. The last argument list can be used for implicit arguments.

No comments:

Post a Comment