Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
PowerShell example using a hash table and null coalescing to map colour value to name
$colourValue = 0x00FF00
$colourMap = @{
0xFF0000 = 'red'
0x00FF00 = 'green'
0x0000FF = 'blue'
0xFFFFFF = 'white'
}
$colourName = ($colourMap[$colourValue], 0x0, 1 -ne $null)[0] # Null Coalescing
return $colourName
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment