I recall somewhere seeing a function with two parenthesis brackets ()() like:
function add_numbers(number1)(number2)
What do you call such a function and what’s its usage?
Thank you in advance and will be sure to vote up/accept answer
I recall somewhere seeing a function with two parenthesis brackets ()() like:
function add_numbers(number1)(number2)
What do you call such a function and what’s its usage?
Thank you in advance and will be sure to vote up/accept answer
It is called function currying. The first bracket returns another function(lets call it: "myCustomFunc"). The 2nd bracket actually passes the 2nd value (number2) to the myCustomFunc.
Going off of this answer, the add_numbers function takes one argument (number1) and returns a function, which is then called with argument number2.