This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Created by xiaofei on 2018/11/30. | |
* desc:Boolean Extension, Say Goodbye to if-else expression | |
*/ | |
sealed class BooleanExt<out T>//定义成协变 | |
object Otherwise : BooleanExt<Nothing>()//Nothing是所有类型的子类型,协变的类继承关系和泛型参数类型继承关系一致 | |
class TransferData<T>(val data: T) : BooleanExt<T>()//data只涉及到了只读的操作 |