Avatar
@swift-4.2.4 protocol Hoge { associatedtype Fuga func piyo(_ index: Int) -> Fuga } extension Array: Hoge where Element == String { typealias Fuga = String func piyo(_ index: Int) -> Fuga { return self[index] } } extension Array: Hoge where Element == Int { typealias Fuga = Int func piyo(_ index: Int) -> Fuga { return self[index] } } (edited)