The former employs currying, the latter is something you're probably more familiar with from languages like C, C++, etc.
Currying is something that is prominent in functional programming languages.. functional programming languages place the idea of functions and function chaining in high regard so something like
def transform(f: Double => Double)(input: Double)
Can be seen as something that takes as a single argument a function Double => Double and returns another function that takes as a single argument a Double and returns a Double.
As Programming in Scala discusses, function currying also let's us do some nifty things, two of which come to mind are
- type inference
- new control abstractions
For type inference, consider something like foldLeft.
val myVector = Vector(1, 2, 3, 4) myVector.foldLeft(0.0)(_ + _)
foldLeft is curried, and us specifying 0.0 as the initial value let's the type inferencer know we want our final result to be a Double.
For new control abstractions, we can do something like
def doWithFileAndClose(file: File)(func: () => Unit): Unit = try { func() } finally { file.close }
which would be used like
doWithFileAndClose("somefile.txt") { /* do stuff */ }
This takes advantage that Scala will accept curly braces in place of parentheses, which makes the above look just like familiar control structures such as for and while loops.