Hacker News new | ask | show | jobs
by bww 1780 days ago
This sort of thing is a common pattern in Go, where it is accomplished by the fact that Go interfaces do not require types to opt into them by declaring their adoption. If a type conforms to the interface it's a type of the interface.

So one can create a new interface type that supports the specific subset of functionality you need from a larger type that you don't control and use it in a similar way to Swift protocols.

1 comments

While you have to declare it, you can do the same in Swift using an extension.