emmanueltouzery / prelude-ts

Functional programming, immutable collections and FP constructs for typescript and javascript
ISC License
377 stars 21 forks source link

Fix: EmptyHashMap does not implement containsKey #10

Closed antoine-wdg-rmz closed 6 years ago

antoine-wdg-rmz commented 6 years ago

(and add unit tests on containsKey)

IMO EmptyHashMap should not inherit HashMap and simply implement IMap, this would catch errors like that.

emmanueltouzery commented 6 years ago

perfect! Good idea about implementing IMap, the only thing is that HashMap may have some extra methods compared to IMap, so that could be problematic. I agree things are a little poor in that area.

The other thing is that maybe there's a way that we don't need two classes to begin with, I wrote this comment in the source:

// we need to override the empty hashmap // because i don't know how to get the hash & keyset // functions for the keys without a key value to get // the functions from

Well, for linked list we make the dichotomy (empty/not empty) public, and even take advantage of it, so who knows, maybe it's even not a bad thing.

I'll make a quick bugfix release since that's a bit of a bigger issue.

emmanueltouzery commented 6 years ago

0.7.9 is on npm with your fix! Thank you again!