Skip to content

Instantly share code, notes, and snippets.

@Sambardo
Created February 28, 2018 19:24
Show Gist options
  • Save Sambardo/c11291b009f98d634dba0490bf2197c8 to your computer and use it in GitHub Desktop.
Save Sambardo/c11291b009f98d634dba0490bf2197c8 to your computer and use it in GitHub Desktop.
careful with break!
$nums = 1..15
Switch($nums)
{
{$_ -lt 5} {write-host "$_ is less than 5!" -ForegroundColor Magenta;break}
{$_ -lt 10} {write-host "$_ is less than 10!" -ForegroundColor green;break}
{$_ -lt 15} {write-host "$_ is less than 15!" -ForegroundColor cyan;break}
default {write-host "$_ is greater than or equal to 15" -ForegroundColor yellow}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment