Esteban A. Maringolo wrote:
I wouldn't start a flamewar on this, but being able to separate
equality and identity is important.
Otherwise we should have to remove #= or #== since of either is redundant. :)
If you're dealing with ORM having a good implementation of #= is
important, since you might have several instances representing the
same "abstraction" (I wouldn't call it an object). Then you have to
implement #hash as well.
What is wrong most of the times is the implementation of #= and #hash itself.
I remember that Eclipse for Java provides Herbert's required feature,
where it can coherent equals() and hashcode() functions based on the
attributes of your choice.
Regards!
Esteban A. Maringolo
2018-02-07 17:09 GMT-03:00 Norbert Hartl<norb...@hartl.name>:
I think that implementing = and hash is almost always wrong. So I guess the
answer is no :)
Just as mechanically generated initializers / accessors are not always
directly what you want, you then change them later, but: it is helpful
to be able to generate the default version of them.
I though the same for the #=/#hash pair.
Never thought it would cause a flame (just a "is it important enough"
discussion)...
Herby
Norbert
Am 07.02.2018 um 17:10 schrieb Herbert Vojčík<he...@mailbox.sk>:
Hi!
Do you think it would be reasonable to have, a la "generate accessors" / "generate initialize
method", a "generate equality" thingie that would generate #= and #hash for the method,
mechanically?
Just created a new "piece of data" class and felt like it would be helpful.
Herby