From 79e7bf46de416adf7e79c39a5c6e37e978ce54b8 Mon Sep 17 00:00:00 2001 From: Heshan Padamsiri Date: Tue, 12 Nov 2024 08:21:48 +0530 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Maryam Ziyad --- examples/distinct-object-types/distinct_object_types.bal | 4 +++- examples/distinct-object-types/distinct_object_types.md | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/examples/distinct-object-types/distinct_object_types.bal b/examples/distinct-object-types/distinct_object_types.bal index 52011fc9ee..a696f72b30 100644 --- a/examples/distinct-object-types/distinct_object_types.bal +++ b/examples/distinct-object-types/distinct_object_types.bal @@ -17,9 +17,11 @@ distinct class DistinctPerson { } } -// SomeWhatDistinctPerson is a subtype of DistinctPerson since inherit the same type ID via inclusion +// The `SomeWhatDistinctPerson` type is a subtype of the `DistinctPerson` type +// since it includes the `DistinctPerson` type's type IDs via inclusion. class SomeWhatDistinctPerson { *DistinctPerson; + public string name; function init(string name) { diff --git a/examples/distinct-object-types/distinct_object_types.md b/examples/distinct-object-types/distinct_object_types.md index 4f64e27724..cd344354ec 100644 --- a/examples/distinct-object-types/distinct_object_types.md +++ b/examples/distinct-object-types/distinct_object_types.md @@ -1,7 +1,8 @@ # Distinct object types -For more explicit control over object type relations you can use `distinct` object types. Each distinct object type declaration has a unique type ID. When you include a distinct object type within another object type declaration, the new type's type ID set will include the type ID of the included type. When checking if a given object type `OSub` is a subtype of a distinct object type `OSuper` there is the additional requirement that `OSub` must contain all the type IDs of `OSuper`. -This way you can achieve the same behavior as a nominal type system within the Ballerina's structured type system, which is useful for things such as GraphQL API interfaces. +For more explicit control over object type relations you can use `distinct` object types. Each distinct object type declaration has a unique type ID. When you include a distinct object type within another object type declaration, the new type's type ID set will include the type IDs of the included type. When checking if a given object type `OSub` is a subtype of a distinct object type `OSuper` there is the additional requirement that `OSub` must contain all the type IDs of `OSuper`. + +This way you can achieve the same behavior as a nominal type system within Ballerina's structured type system, which is useful to support features such as GraphQL API interfaces. ::: code distinct_object_types.bal :::