Mick
Mick

Reputation: 31959

Typealias - Combine Multiple Interfaces in Kotlin

I'm a bit rusty with protocol composition in Kotlin, I'd just like to combine multiple interfaces by declaring a custom typealias:

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

Any ideas?


In Swift, I would do it this way:

typealias MyType = ReadableInterface & WritableInterface

In Objective C, I would do it this way:

typedef <ReadableInterface, WritableInterface> MyType; 

Upvotes: 13

Views: 3818

Answers (1)

Evgeny  Bovykin
Evgeny Bovykin

Reputation: 3079

Why not just create new interface?

interface MyType : ReadableInterface, WritableInterface

Upvotes: 9

Related Questions