-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Swift protocol #159
Comments
Protocol associatedtype with array. WORKS for
protocol Actionable {
}
protocol M: class {
associatedtype Action: Actionable
var views: [Action] { get set }
}
func f(view: Actionable) {
}
func g(views: [Actionable]) {
}
extension M {
func add(view: Action) {
views.append(view)
f(view)
g(views)
}
} Oops, it is the same error for generic struct, too 😢 protocol Actionable {
}
struct M<T: Actionable> {
var views: [T]
}
func g(views: [Actionable]) {
}
extension M {
func add() {
g(views)
}
} |
Use protocol as a generic constraint 🐼
|
This was referenced Jun 4, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Extending generic struct with inheritance protocol. WORK 🎉 . But autocompletes shows all methods 😢
The text was updated successfully, but these errors were encountered: