Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Function ?? (IfNull)
Function Get-IfNull($Value, $DefaultValue)
{
if($Value -eq $null)
{
return $DefaultValue
}
return $Value
}
Set-Alias '??' Get-IfNull
# $a = $null
# $b = 'default'
#
# echo (?? $a $b) // returns 'default'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment