Hi @pretaporter
, thanks for the article. I want to discuss a part of the class if you are willing to. I believe in the set(k, v) that you should not look at the union in the if statement, but rather the intersection (&& vs. ||) as having either of them being defined without the other should rather be an error in the implementation. If that is true you should rather throw an error or something to show that the bi-directional map is malformed. Cheers.
Sure, thanks for your point. Why do you think we should use intersection instead?
If we will use intersection, then will be possible situation like this:
xx.set('a','b');xx.set('c','b');xx.getKey('b');// returns c
It is not correct
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hi @pretaporter , thanks for the article. I want to discuss a part of the class if you are willing to. I believe in the
set(k, v)
that you should not look at the union in theif
statement, but rather the intersection (&&
vs.||
) as having either of them being defined without the other should rather be an error in the implementation. If that is true you should rather throw an error or something to show that the bi-directional map is malformed. Cheers.Sure, thanks for your point. Why do you think we should use intersection instead?
If we will use intersection, then will be possible situation like this:
It is not correct