-
Notifications
You must be signed in to change notification settings - Fork 402
Closed
Description
Creating a hashtable via the constructor without specifying an
IEqualityComparerresults in using the default IEqualityComparer (which uses Object::Equals), which means that strings are compared in a case-sensitive way. This may be confusing and unexpected to PowerShell scripters who are accustomed to case-insensitive hashtables.
Basically, I think you should warn people if you see:
New-Object System.Collections.Hashtable
[hashtable]::new()
Or any variation on those: (System.Collections.Hashtable = Collections.Hashtable = Hashtable) with or without parameters (unless the parameters include a custom IEqualityComparer).
The warning should recommend creating hashtables with the literal initializer @{} for speed (over New-Object) and case-sensitivity reasons as cited above.