diff --git a/examples/index.json b/examples/index.json index 0863c62cd5..1fc98629de 100644 --- a/examples/index.json +++ b/examples/index.json @@ -459,7 +459,7 @@ "name": "List subtyping", "url": "list-subtyping", "verifyBuild": true, - "verifyOutput": false, + "verifyOutput": true, "isLearnByExample": true }, { diff --git a/examples/list-subtyping/list_subtyping.bal b/examples/list-subtyping/list_subtyping.bal index b4c4a1e823..c8c4773fc9 100644 --- a/examples/list-subtyping/list_subtyping.bal +++ b/examples/list-subtyping/list_subtyping.bal @@ -2,25 +2,26 @@ import ballerina/io; public function main() { int[3] numbers = [144, 232, 322]; + // `numbers`, of type `int[3]`, will be a subtype of `int[]` + // since `T[n]` is a subtype of `T[]` io:println(numbers is int[]); byte[3] numbers2 = [1, 2, 3]; - // `numbers2` will be a subtype of `int[3]` + // `numbers2`, of type byte[3], will be a subtype of `int[3]` // since `byte` is a subtype of `int` and lengths are the same io:println(numbers2 is int[3]); - // `numbers2` will be a subtype of `int[]` - // since `byte` is a subtype of `int` and `T[n]` is a sub type of `T[]` + // `numbers2`, of type byte[3], will be a subtype of `int[]` + // since `byte` is a subtype of `int` and `T[n]` is a subtype of `T[]` io:println(numbers2 is int[]); [byte, string] person = [1, "Mike"]; - // `[byte, string]` is a sub type of `[int, anydata]` + // `[byte, string]` is a subtype of `[int, anydata]` io:println(person is [int, anydata]); - // `[byte, string]` is a sub type of `[int, anydata...]` + // `[byte, string]` is a subtype of `[int, anydata...]` io:println(person is [int, anydata...]); - // `int[3]` is a sub type of `[int, anydata...]` + // `int[3]` is a subtype of `[int, anydata...]` io:println(numbers is [int, anydata...]); } - diff --git a/examples/list-subtyping/list_subtyping.out b/examples/list-subtyping/list_subtyping.out index c60983457a..edd1e4cb04 100644 --- a/examples/list-subtyping/list_subtyping.out +++ b/examples/list-subtyping/list_subtyping.out @@ -1,5 +1,7 @@ -$ bal run list_sub_typing.bal -[0,0,0] -[false] -["John","Mike",""] -[["carrot","apple"],["avocado","egg"],["",""]] +$ bal run list_subtyping.bal +true +true +true +true +true +true