3 ms·
But this is also achievable with static init methods on records and value classes, right? record Rational(int num, int denom) { Rational { in
by gavinray 1y ago
But this is also achievable with static init methods on records and value classes, right?
record Rational(int num, int denom) {
Rational {
int gcd = gcd(num, denom);
num /= gcd;
denom /= gcd;
}
}
- sagacity 1y agoHow would you do the same thing with the late initialization of, say, a HashMap where you don't control the constructor?