Appendix: Subtyping rules
Subtypes and supertypes
// Example 1: we can assign a value of type boolean
// to a variable of type boolean?.
// In other words, boolean is a subtype of boolean?.
let x: boolean = false;
let y: boolean? = x; // no problem// Example 2: we cannot assign any value of type boolean?
// to a variable of type boolean.
// In other words, boolean? is not a subtype of boolean.
let x: boolean? = null;
let y: boolean = x; // Type mismatchRecord subtyping
Lowest common supertype
Last updated
Was this helpful?