Java 14 brings records, which are a great addition seen in many functional languages:
Java:
public record Vehicle(String brand, String licensePlate) {}
ML:
type Vehicle =
{
Brand : string
LicensePlate : string
}
In ML languages, it is possible to "update" a record by creating a copy with a few values changed:
let u =
{
Brand = "Subaru"
LicensePlate = "ABC-DEFG"
}
let v =
{
u with
LicensePlate = "LMN-OPQR"
}
// Same as:
let v =
{
Brand = u.Brand
LicensePlate = "LMN-OPQR"
}
Is this possible in Java 14?