Skip to content

Instantly share code, notes, and snippets.

@wolftatsu
Created January 20, 2014 02:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wolftatsu/8514105 to your computer and use it in GitHub Desktop.
Save wolftatsu/8514105 to your computer and use it in GitHub Desktop.
[PowerShell]Can I write code that build closure?
$givenValue = 10
function testIfSupportingClosure(){
$givenValue = 4
{
$script:givenValue = $givenValue + 1
echo "The givenValue is ${givenValue}."
}.GetNewClosure()
}
$closureA = testIfSupportingClosure
$closureA.invoke() # The givenValue is 5.
$closureA.invoke() # The givenValue is 6.
$closureA.invoke() # The givenValue is 7.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment