Subtypes
In Rell, the concept of subtypes enhances code flexibility and reusability by allowing seamless assignment between compatible types.
If type B is a subtype of type A, you can freely assign a value of type B to a variable of type A or pass it as
an argument to a function expecting type A.
Common subtype relationships
-
Optional types:
Tis a subtype ofT?(a non-nullable type is a subtype of its nullable counterpart).nullis a subtype ofT?(null can be assigned to any nullable type).
-
Tuples:
(T, P)is a subtype of(T?, P?),(T?, P), and(T, P?)(tuples with more specific types are subtypes of tuples with more general types).