PS> $hashCollision = @{ count = "2" }
PS> $hashCollision.Count
2
So I cannot trust even PowerShell now... (never could)
Now that I know it gives priority to the keys instead of properties, what should I do? Live in constant fear that one day some of my old code is gonna suddenly fail and I will be none the wiser? Or go through all of it and change all the .Count calls to intrinsic members, like .get_Count() or psbase.count (with the latter also failing in some cases)?
We're talking dynamically populated hashtables here, no control over the input data — I was lucky the value happened to be Generic.List and not just string, otherwise I would never have caught it.
So what now? Future code is no problem — lesson learned. But what about the old code?
P.S. Yes, I did read about it in the about_Hash_Tables article a long time ago, but it is just a small little note, not much attention drawn to it.
P.P.S. Personally, I think it was a bad decision to let users access the keys with dot notation instead of only allowing ["key"]. And even then it could've been avoided if priorities were set differently.