I’m on the cutting edge, but my writing isn’t always there with me. When a new PowerShell feature is released, it’s not often me that’s telling you about it. That said, if it’s about trying something, or sharing something “cutting edge” at work, then that’s a different story. Well, this is a bit of a different story, too.
While it’s already been introduced, the Ternary operator joined us in one of the preview releases of PowerShell 7. As of this writing, PowerShell 7 rc2 has recently been introduced and the Ternary operator is still an experimental feature. This means, don’t use it in production just yet, as it could change and cause breaking changes for you. Before I go on, and in case you need to educate yourself about the Ternary operator, then read though this link: https://toastit.dev/2019/09/25/ternary-operator-powershell-7. I put this on Twitter recently and picked up several Retweets and Likes! Perhaps I should write about cutting edge PowerShell topics. One person replied as though I wrote that article; nope, that wasn’t mine. This one is, however.
The Ternary operator allows you to simplify an If-Else statement, such as <condition> ? <If true> : <If false>. I liked the new inclusion in PowerShell the first time I saw it, but today I wondered something. I eventually tested it, and as a result, I’ve authored a new article. Let discuss more at https://tommymaynard.com (direct link).
≥ Tommy Maynard (Twitter: @thetommymaynard)