- Functional Kotlin
- Mario Arias Rivu Chakraborty
- 126字
- 2021-06-24 19:15:22
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
推薦閱讀
- The Modern C++ Challenge
- 深入淺出WPF
- PHP+MySQL網站開發技術項目式教程(第2版)
- 21天學通C++(第6版)
- 大學計算機基礎實驗指導
- Bootstrap for Rails
- 遠方:兩位持續創業者的點滴思考
- 超簡單:Photoshop+JavaScript+Python智能修圖與圖像自動化處理
- Software Development on the SAP HANA Platform
- Implementing Microsoft Dynamics NAV(Third Edition)
- 原型設計:打造成功產品的實用方法及實踐
- Python數據預處理技術與實踐
- C++面向對象程序設計
- TypeScript High Performance
- 深入理解Zabbix監控系統