Skip to content

Instantly share code, notes, and snippets.

@dmalikov
Last active August 29, 2015 13:57
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 dmalikov/9916744 to your computer and use it in GitHub Desktop.
Save dmalikov/9916744 to your computer and use it in GitHub Desktop.
powershell wow so pure very functional
$ cat function.ps1
function f() {
{ param($x) "expected output" }.Invoke()
}
function g() {
{ param($x) "unexpected" }.Invoke()
return "output"
}
Write-Host (f).GetType()
Write-Host (g).GetType()
$ powershell ./function.ps1
System.String
System.Object[]
$ cat function.ps1
function func() {
{ param($x) "un" }.Invoke()
$res = "expected"
Write-Host $res
return $res
}
Write-Host(func)
$ powershell ./function.ps1
expected
un expected
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment