Skip to content

Instantly share code, notes, and snippets.

@hannesstruss
Last active November 28, 2016 18:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hannesstruss/520eee7ae806323e1c0ebc3f8ac7f383 to your computer and use it in GitHub Desktop.
Save hannesstruss/520eee7ae806323e1c0ebc3f8ac7f383 to your computer and use it in GitHub Desktop.
//: Playground - noun: a place where people can play
import UIKit
import RxSwift
protocol ListSource {
associatedtype ItemT
func getItems(index: Int) -> [ItemT]
}
class ActualSource: ListSource {
typealias ItemT = String
func getItems(index: Int) -> [String] {
return ["Hallo", "Na"]
}
}
let l: Array<String>
class Storage<T, ListSourceT: ListSource> where ListSourceT.ItemT == T {
let ls: ListSourceT
init(_ listSource: ListSourceT) {
ls = listSource
let items: [T] = ls.getItems(index: 2)
print(items.count)
}
}
let actualSource = ActualSource()
let stringStorage = Storage(actualSource)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment