For anyone interested. The correct idea should go into this direction one day:
public class Router<B> { open protocol Connection<T> : class { var router: Router<T> { get set } func performWith(_ value: T) } var _connections: [Connection<B>] = [] public typealias Connections = Any<Collection> where Collection.Index == Int, Collection.Iterator.Element == B // Immutable view without `append` etc. public connections: Connections { return self._connections } public func register(_ connection: Connection<B>) { … } public func performWith(_ value: B) { self._connections.forEach { $0.performWith(value) } } } The main idea is to link different nodes (class instances) and call a function on the other end with a specific type parameter. Enums with associated types would come really handy here. -- Adrian Zubarev Sent with Airmail Am 2. Dezember 2016 um 17:35:25, Tino Heth (2...@gmx.de) schrieb: Thanks, that works party as needed but I just realize this main idea here is exactly an example where one would need generic protocols That's right — and I guess they rank quite hight on the general evolution-wishlist ;-)
_______________________________________________ swift-users mailing list swift-users@swift.org https://lists.swift.org/mailman/listinfo/swift-users