我对Kotlin中的协议组成有些不满意,我只想通过声明自定义typealias
来组合多个接口:
// This doesn't work
typealias MyType = (ReadableInterface && WritableInterface)
有什么想法吗?
在Swift中,我会这样:
typealias MyType = ReadableInterface & WritableInterface
在Objective C中,我会这样做:
typedef <ReadableInterface, WritableInterface> MyType;
interface MyType : ReadableInterface, WritableInterface