From 209f02660f7adf2c313195339a28009d5d756639 Mon Sep 17 00:00:00 2001 From: MaryamZi Date: Thu, 10 Oct 2024 15:02:25 +0530 Subject: [PATCH] Use unions with nil instead of optional types --- examples/unions/unions.bal | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/unions/unions.bal b/examples/unions/unions.bal index 7da8f1afbc..cd22af6c5a 100644 --- a/examples/unions/unions.bal +++ b/examples/unions/unions.bal @@ -20,7 +20,7 @@ public function main() { io:println(nameToString(name1)); io:println(nameToString(name2)); - map grades1 = { + map grades1 = { math: "80", physics: (), chemistry: "76" @@ -58,10 +58,10 @@ function nameToString(Name nm) returns string { } } -function parseGrades(map grades) returns map|error { +function parseGrades(map grades) returns map|error { map parsedGrades = {}; - foreach [string, string?] [subject, grade] in grades.entries() { + foreach [string, string|()] [subject, grade] in grades.entries() { // If the `grade` value is `()`, continue on to the next entry. if grade is () { continue;