February 2018
Intermediate to advanced
350 pages
7h 35m
English
Type alias provides a way to define names of types that already exist. Type alias can help to make complex types easier to read, and can also provide other hints.
The Oven interface is, in some sense, just a name, for a Machine<Bakeable>:
typealias Oven = Machine<Bakeable>
Our new type alias, Oven, is exactly like our good old Oven interface. It can be extended and have the values of the type Oven.
Types alias also can be used to enhance information on types, providing meaningful names related to your domain:
typealias Flavour = Stringabstract class BakeryGood(val flavour: Flavour) {
It can also be used on collections:
typealias OvenTray = List<Bakeable>
It can also be used with objects:
typealias CupcakeFactory = Cupcake.Companion ...
Read now
Unlock full access