3 ms·
I think you mean var, not val. If you were using val you would do: class Kitty(val purrVolue: Int) which would turn out to be in Java: public class Kitt
by pretzel 16y ago
I think you mean var, not val.
If you were using val you would do:
class Kitty(val purrVolue: Int)
which would turn out to be in Java:
public class Kitty {
private final int purrVolume;
public Kitty(final int purrVolume) {
this.purrVolume = purrVolume;
}
public int getPurrVolume() { return purrVolume; }
}
- narrator 16y agoOn the Java version you forgot equals() and hashcode(). Scala's case classes give you that for free.