79554359

Date: 2025-04-04 02:49:17
Score: 0.5
Natty:
Report link
record MyRecord(int a, int b, int hash) {

    MyRecord(int a, int b) {
        this(a, b, Objects.hash(a, b));
    }

    @Deprecated
    MyRecord {
    }

    @Override
    public int hashCode() {
        return hash;
    }
}

That said, I consider this an odd usage of records and would never do it myself. If I was convinced that I needed to precompute hash codes I would go with an old fashioned hand written value class.

Reasons:
  • Blacklisted phrase (0.5): I need
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Juan C Nuno