Skip to content

Commit

Permalink
Fix issues in BBEs
Browse files Browse the repository at this point in the history
  • Loading branch information
MaryamZi committed Sep 20, 2024
1 parent c833334 commit 38c7c14
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
6 changes: 3 additions & 3 deletions examples/match-statement/match_statement.bal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import ballerina/io;

const switchStatus = "ON";
const SWITCH_STATUS = "ON";

function matchValue(any val) returns string {
// The value of the `val` variable is matched against the given value match patterns.
Expand All @@ -15,7 +15,7 @@ function matchValue(any val) returns string {
"STOP" => {
return "STOP";
}
switchStatus => {
SWITCH_STATUS => {
return "Switch ON";
}
// Use `_` to match type `any`.
Expand All @@ -30,6 +30,6 @@ public function main() {
io:println(matchValue(1));
io:println(matchValue(2));
io:println(matchValue("STOP"));
io:println(matchValue(switchStatus));
io:println(matchValue(SWITCH_STATUS));
io:println(matchValue("default"));
}
7 changes: 6 additions & 1 deletion examples/open-records/open_records.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Open records

A record type that uses either the `{` and `}` delimiters or the `{|` and `|}` delimiters with a rest descriptor is considered open. They allow fields other than those specified. The type of unspecified fields is `anydata`. Open records belong to `map<anydata>`. Quoted keys can be used to specify fields that are not mentioned in the record type.
A record type that uses either the `{` and `}` delimiters or the `{|` and `|}` delimiters with a rest descriptor is considered open. Open records allow fields other than those explicitly specified.

When the record is open due to using the `{` and `}` delimiters, the expected type for any additional field is `anydata`. Such records belong to `map<anydata>`.

Quoted keys can be used to specify fields that are not explicitly specified in an open record type.

::: code open_records.bal :::

Expand All @@ -10,3 +14,4 @@ A record type that uses either the `{` and `}` delimiters or the `{|` and `|}` d
- [Records](/learn/by-example/records/)
- [Controlling openness](/learn/by-example/controlling-openness/)
- [Maps](/learn/by-example/maps/)
- [Anydata type](/learn/by-example/anydata-type/)
4 changes: 3 additions & 1 deletion examples/xml-access/xml_access.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ It is possible to access elements in XML.

- `x.id` accesses the required attribute named `id`: the result is an error if there is no such attribute or if `x` is not a singleton.

- `x?.id` accesses an optional attribute named `id`: the result is `()` if there is no such attribute. The `lang.xml` langlib provides the other operations.
- `x?.id` accesses an optional attribute named `id`: the result is `()` if there is no such attribute.

The `lang.xml` langlib provides the other operations.

::: code xml_access.bal :::

Expand Down

0 comments on commit 38c7c14

Please sign in to comment.