Created
August 13, 2018 11:09
-
-
Save Manuri/7c991a4d9775394aac6115d640ed4549 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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