RosettaCodeData/Task/Associative-array-Iteration/Ballerina/associative-array-iteration...

23 lines
624 B
Plaintext

import ballerina/io;
public function main() {
// create a new map with four entries
map<string> capitals = {
"France": "Paris",
"Germany": "Berlin",
"Russia": "Moscow",
"Spain": "Madrid"
};
// iterate through the map and print out the key/value pairs
foreach var e in capitals.entries() { io:println(e); }
io:println();
// iterate though the map and print out just the keys
foreach var k in capitals.keys() { io:println(k); }
io:println();
// iterate through the map and print out just the values
foreach var v in capitals { io:println(v); }
}