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

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
主站蜘蛛池模板: 陈巴尔虎旗| 宜兰县| 乡城县| 吉安县| 慈溪市| 科技| 四川省| 林甸县| 华阴市| 黄浦区| 格尔木市| 龙州县| 朝阳区| 保山市| 大同市| 资源县| 镇巴县| 南投市| 张家口市| 来宾市| 库车县| 海宁市| 威海市| 双峰县| 和平县| 柳林县| 涟源市| 南宁市| 凤庆县| 安塞县| 沂南县| 尚志市| 乌拉特后旗| 虹口区| 顺平县| 固阳县| 玉门市| 蒙自县| 辽阳县| 马尔康县| 射洪县|