From 8d338ad160748dc80256c53b72004aed19db6e92 Mon Sep 17 00:00:00 2001 From: poorna2152 Date: Wed, 10 Apr 2024 10:26:54 +0530 Subject: [PATCH] Add record type to store result --- examples/index.json | 7 +++++++ examples/multiple-receive/multiple_receive.bal | 15 ++++++++++----- .../multiple-receive/multiple_receive.metatags | 2 +- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/examples/index.json b/examples/index.json index f8fce98279..5fa32edb77 100644 --- a/examples/index.json +++ b/examples/index.json @@ -1475,6 +1475,13 @@ "verifyOutput": true, "isLearnByExample": true }, + { + "name": "Multiple receive", + "url": "multiple-receive", + "verifyBuild": true, + "verifyOutput": true, + "isLearnByExample": true + }, { "name": "Conditional send", "url": "conditional-send", diff --git a/examples/multiple-receive/multiple_receive.bal b/examples/multiple-receive/multiple_receive.bal index 7d87c7ede2..bab76d17b5 100644 --- a/examples/multiple-receive/multiple_receive.bal +++ b/examples/multiple-receive/multiple_receive.bal @@ -1,6 +1,11 @@ import ballerina/io; import ballerina/lang.runtime; +type Result record { + int w1; + int w2; +}; + public function main() { worker w1 { 2 -> w3; @@ -11,13 +16,13 @@ public function main() { 3 -> w3; } - worker w3 returns map { + worker w3 returns Result { // The worker waits until both values are received. - map result = <- {w1, w2}; + Result result = <- {w1, w2}; return result; } - map results = wait w3; - io:println(results["w1"]); - io:println(results["w2"]); + Result result = wait w3; + io:println(result.w1); + io:println(result.w2); } diff --git a/examples/multiple-receive/multiple_receive.metatags b/examples/multiple-receive/multiple_receive.metatags index 5bd33b75fc..447cf56e84 100644 --- a/examples/multiple-receive/multiple_receive.metatags +++ b/examples/multiple-receive/multiple_receive.metatags @@ -1,2 +1,2 @@ -description: This BBE demonstrates the multiple receive action. +description: This BBE demonstrates the use of the multiple receive action in inter-worker communication keywords: ballerina, ballerina by example, bbe, worker, multiple receive