Consider these two statements:
$result = [bool]$SomeObject
$result = if ($SomeObject) { $true } else { $false }
These two statements seem equivalent, but I am often surprised by PowerShell's quirks. Normally I'd try to work this kind of thing out from a language specification, but the closest thing to that seems to be stackoverflow.
Are the above two statements equivalent for all possible types and values of
$SomeObject
?Is the answer to (1) actually baked into the CLR? If so, how can I tell that is the case?