Addition of two numbers using a function in swift language

Addition of two numbers using a function in swift language. This program will execute the swift program outside of the condition and it will print the output through the return statement in swift programming language

let sum = 
{
(a: Int, b: Int) -> Int in
return a + b
}
let number = sum(20,30)
print(number)

 

Output:

50

What is let keyword in swift

The let keyword in Swift can be used to create immutable variables. A constant that can only be initialised once is called an immutable variable. If you try to reassign, reinitialize, or change a let variable, you’ll get a compiler error. Var variables, on the other hand, can be altered. Let and var are two basic strategies for storing values that a programmer can access using a name. If you’ll never change the value associated with that name, use let.