in reply to Re: Trimming whitespaces methods
in thread Trimming whitespaces methods
It's an edge case for sure but you can't rule out having " keyone" and "keyone". If you suspect there is leading and trailing space on your keys (and hence the question) it becomes less of an edge case. You'll have lost data and not noticed.
It must be better to do your trimming (keys and values) while building the hash, not after (you can use exists to catch any resulting dupes). If that's not possible/feasable I'd go for creating a hash of arrays and go through and count the little blighters.
Did I mention I've been bitten so often by stray whitespace (it's everywhere!) that I've become a tad obsessive? :-)
|
---|