Work on a Powershell script I had several places where I wanted A, if it was not null, otherwise B. In fact, a statement in C #. I have finished writing the function shown below, but I cannot help but think that there is a built-in way to do this.
Is there a better, built-in way?
function Get-ValueOrDefault() { foreach ($value in $args) { if ($value -ne $null) { return $value } } }
I think this works better:
function Get-ValueOrDefault() { $args | select -first 1 }
powershell
Oldfart
source share