Swift part9 [無断転載禁止]©5ch.io
■ このスレッドは過去ログ倉庫に格納されています
0837デフォルトの名無しさん (ワッチョイ d3c9-C9ZD)
2017/02/13(月) 14:45:06.42ID:2bWgE/rs0THX!
Generic protocols
One of the most commonly requested features is the ability to parameterize protocols themselves.
これこれ!俺もコレが欲しかった!
protocol ConstructibleFromValue<T> {
init(_ value: T)
}
こうすると、構造体Realに対して2種類のinitの実装を求める事ができる。
これの何が問題なんだ?
struct Real { ... }
extension Real : ConstructibleFrom<Float> {
init(_ value: Float) { ... }
}
extension Real : ConstructibleFrom<Double> {
init(_ value: Double) { ... }
}
■ このスレッドは過去ログ倉庫に格納されています