Skip to content

Instantly share code, notes, and snippets.

@Manuri
Created August 13, 2018 11:09
Show Gist options
  • Save Manuri/7c991a4d9775394aac6115d640ed4549 to your computer and use it in GitHub Desktop.
Save Manuri/7c991a4d9775394aac6115d640ed4549 to your computer and use it in GitHub Desktop.
import ballerina/io;
type Salary record {
int id,
float salary,
};
type Person record {
int id,
float salary,
string name,
};
function main(string... args) {
table<Person> dt;
Person p1 = { id: 1, name: "A", salary: 100 };
Person p2 = { id: 2, name: "B", salary: 200 };
Person p3 = { id: 3, name: "C", salary: 300 };
_ = dt.add(p1);
_ = dt.add(p2);
_ = dt.add(p3);
table<Salary> salaries = dt.select(getSalary);
io:println(salaries);
}
function getSalary(Person p) returns Salary {
Salary s = { id: p.id, salary: p.salary };
return s;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment