Daniel Little Coding Blog
Daniel Little Coding Blog

A blog about .net development and the web.

Daniel Little
Author

Daniel Little (lavinski) is a Brisbane based software developer.

Share


Our Newsletter


Like this blog? Get each new post as soon it's posted.

Tags


Twitter


Self executing anonymous function in Powershell

Daniel LittleDaniel Little

One of the great features of JavaScript is the self-executing anonymous function. It's extremely useful because you can avoid polluting the global scope and express your dependencies in an explicit manner.

PowerShell lets you do something similar by taking advantage of blocks, the param keyword and the call operator &.

& { param($msg) Write-Host $msg } "Hello World"

This function will be automatically invoked with the string "Hello World".

Daniel Little
Author

Daniel Little

Daniel Little (lavinski) is a Brisbane based software developer.

Comments