Closures¶
Closures are functions that capture variables from their surrounding scope.
Basic Closure¶
let multiplier = 3;
let multiply_by = |x| => {
return x * multiplier; // Captures 'multiplier'
};
print multiply_by(5); // 15
print multiply_by(10); // 30