Typealias-在Kotlin中组合多个接口

问题描述 投票:1回答:1

我对Kotlin中的协议组成有些不满意,我只想通过声明自定义typealias来组合多个接口:

// This doesn't work
typealias MyType = (ReadableInterface && WritableInterface)

有什么想法吗?


Swift中,我会这样:

typealias MyType = ReadableInterface & WritableInterface

Objective C中,我会这样做:

typedef <ReadableInterface, WritableInterface> MyType; 
java kotlin
1个回答
0
投票
为什么不仅仅创建新界面?

interface MyType : ReadableInterface, WritableInterface

© www.soinside.com 2019 - 2024. All rights reserved.