Created
January 20, 2014 02:49
-
-
Save wolftatsu/8514105 to your computer and use it in GitHub Desktop.
[PowerShell]Can I write code that build closure?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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