官术网_书友最值得收藏!

Type alias

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 = String

abstract 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
主站蜘蛛池模板: 灌阳县| 营山县| 富平县| 定南县| 登封市| 永定县| 白城市| 新建县| 昌平区| 共和县| 屏山县| 呼玛县| 丹寨县| 通化县| 咸阳市| 洪雅县| 阜城县| 沾化县| 天水市| 岳阳市| 巴楚县| 缙云县| 南通市| 宁海县| 山东省| 西青区| 大城县| 环江| 开原市| 奈曼旗| 云林县| 临漳县| 旅游| 大连市| 莱芜市| 盈江县| 龙川县| 喀喇沁旗| 嘉荫县| 周口市| 同江市|