thanks everybody

J

Jean Lutrin

Hi everybody,

thanks a lot for all the answers, it helped me a lot.

A Set is indeed a more correct abstraction than a Map (even
if, say, an HashSet is implemented using an HashMap).

What I didn't realize was that .equals() and .hashcode() were
supposed to be consistent (I say "supposed" because there's no
doubt that some programmers forget to comply with this rule).

For whatever reason I was thinking that the hash value was
generated from the reference of the object, which was of
course completely false.

As a funny side note, it means the way I solved my problem
while thinking I was wrong is actually correct :)

Thanks a lot for all your answers,

Jean
 
T

Tim Ward

Jean Lutrin said:
What I didn't realize was that .equals() and .hashcode() were
supposed to be consistent (I say "supposed" because there's no
doubt that some programmers forget to comply with this rule).

They are supposed to be consistent. Some programmers don't realise that -
programmers who fail to comply with the rule are, I would guess, mostly
programmers who've never heard of the rule rather than programmers who've
forgotten to do it.

You can get very interesting results if you fail to comply with this rule -
you quite likely get away with it for a while, but weeks or months later,
when you've forgotten how the class in question was implemented, you start
using it in a different way and it all goes pear shaped.
 
D

Daniel Dyer

I know of only one other person who uses that expression. He lives in
Binegar near Bath in Somerset England. Is that a regionalism?

Maybe it's a British thing. It's quite a common expression over here.

Dan.
 
T

Tim Ward

Roedy Green said:
I know of only one other person who uses that expression. He lives in
Binegar near Bath in Somerset England. Is that a regionalism?

Don't think so, think it's in fairly common usage across the UK. (Although I
did grow up in Bristol, 12 miles from Bath.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top