Simplify mapping constructor
If the variable name is equal to the key of the mapping constructor, we can simplify code {k: k}
to {k}
.
Bad Code
type Student record {|
string name;
int age;
string city;
|};
function registerStudent(string name, int age) {
Student s = {name: name, age: age, city: "London"};
//...
}
Good Code
type Student record {|
string name;
int age;
string city;
|};
function registerStudent(string name, int age) {
Student s = {name, age, city: "London"};
//...
}