0

What is the difference and advantage of using those two ways of writing a function (and how the first way of writing a function is called):

def do_something(a:String, b:String)(c:String) :Unit = {}

and

def do_something(a:String, b:String, c:String) :Unit = {}
pme
  • 14,156
  • 3
  • 52
  • 95
Alina
  • 2,191
  • 3
  • 33
  • 68

1 Answers1

0

It is called Currying, Hier you find a description: scala-currying

The advantage is that you can partially apply such a function.

Here from the linked article:

  1. One benefit is that Scala currying makes creating anonymous functions easier.
  2. Scala Currying also makes it easier to pass around a function as a first-class
pme
  • 14,156
  • 3
  • 52
  • 95
  • I would add: you can of cause curry things manually with closures, but explicit syntax for currying is better . – bobah Sep 24 '18 at 12:09