It is never allowed to chain function calls, as in
It is not allowed to chain function calls
Multiple function calls can be chained together
CorrectionHere is what's right.
An expression like
f()(3) is evaluated from left to right: firstly the function
f gets called with no arguments. The resulting value, which we expect to be a function, is then called passing
3 as the first and only argument. The return value of this last call is the value which the overall expression evaluates to.
f() does not produce a function but something else (e.g., a regular number), we get an error.
f can return a function which in turn can be legally called as shown above and as further demonstrated in the next example.