Skip to content

Instantly share code, notes, and snippets.

View iBotasky's full-sized avatar
🐺
Focusing

Botaksy iBotasky

🐺
Focusing
View GitHub Profile
@xiaofeidev
xiaofeidev / BooleanExt
Created November 30, 2018 07:09
Boolean Extension, Say Goodbye to if-else expression
/**
* 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只涉及到了只读的操作