Skip to content

Instantly share code, notes, and snippets.

@Xainey
Created March 31, 2016 20:55
Show Gist options
  • Save Xainey/982591df56c84e683fef1f3c33ebbd29 to your computer and use it in GitHub Desktop.
Save Xainey/982591df56c84e683fef1f3c33ebbd29 to your computer and use it in GitHub Desktop.
$Adder = {
param ([int] $x)
return (
{
param ([string] $y)
return ($x + $y)
}.GetNewClosure()
)
}
Set-Item -Path "Function:Adder" -Value $Adder
$add5 = Adder 5
$add10 = Adder 10
$add5.Invoke(2)
$add10.Invoke(2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment