diff --git a/examples/const-and-final/const_and_final.bal b/examples/const-and-final/const_and_final.bal index 9b3a537307..0f7b601f9a 100644 --- a/examples/const-and-final/const_and_final.bal +++ b/examples/const-and-final/const_and_final.bal @@ -1,15 +1,22 @@ import ballerina/io; +const int MAX_VALUE = 1000; + // Constants can be defined without the type. Then, the type is inferred from the right-hand side. -const MAX_VALUE = 1000; const URL = "https://ballerina.io"; -// The value for variable `msg` can only be assigned once. +// Mapping and list constants can also be defined. +const HTTP_OK = {httpCode: 200, message: "OK"}; +const ERROR_CODES = [200, 202, 400]; + +// The value for the `msg` variable can only be assigned once. final string msg = loadMessage(); public function main() { io:println(MAX_VALUE); io:println(URL); + io:println(HTTP_OK); + io:println(ERROR_CODES); io:println(msg); } diff --git a/examples/const-and-final/const_and_final.metatags b/examples/const-and-final/const_and_final.metatags index f2088bce39..588b1b9ae4 100644 --- a/examples/const-and-final/const_and_final.metatags +++ b/examples/const-and-final/const_and_final.metatags @@ -1,2 +1,2 @@ -description: This BBE demonstrates how const and final values are used in Ballerina. -keywords: ballerina, ballerina by example, bbe, const, final +description: This BBE demonstrates how `const` and `final` values are used in Ballerina. +keywords: ballerina, ballerina by example, bbe, const, final, map const, list const diff --git a/examples/const-and-final/const_and_final.out b/examples/const-and-final/const_and_final.out index f05491beea..76497199b7 100644 --- a/examples/const-and-final/const_and_final.out +++ b/examples/const-and-final/const_and_final.out @@ -1,4 +1,6 @@ $ bal run const_and_final 1000 https://ballerina.io +{"httpCode":200,"message":"OK"} +[200,202,400] Hello World