Programmer
Programmer

Reputation: 37

Closure inside Function

Code snippet

I'm trying to create a calculator using closures and functions. I got until the actual calculation function which takes in two values, then the user can select which operator to use (addition, multiplication, etc). I don't know how to actually return the value of that calculation.

Upvotes: 1

Views: 47

Answers (1)

Paulw11
Paulw11

Reputation: 114783

A closure is, effectively, a function and you simply invoke it as such.

return operator(numberOne:valueOne, numberTwo:valueTwo)

Upvotes: 1

Related Questions