Created
May 10, 2019 10:19
-
-
Save IISResetMe/8a244c279a9eace3d74285395da4f3e3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-DistinctUnion | |
{ | |
param( | |
[array]$Source, | |
[array]$Other | |
) | |
$temp = [System.Collections.Generic.HashSet[object]]::new($Source) | |
$temp.UnionWith($Other) | |
return $temp | |
} | |
$array1 = 1..3 | |
$array2 = 3..5 | |
Get-DistinctUnion -Source $array1 -Other $array2 | |
# This will also work | |
$set1 = [System.Collections.Generic.HashSet[int]]::new([int[]]$array1) | |
$set2 = [System.Collections.Generic.HashSet[int]]::new([int[]]$array2) | |
Get-DistinctUnion -Source $set1 -Other $set2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment