[swift-evolution] Variable with generic protocol type
Rtnm Nosurname
rtnm at me.com
Fri Jun 16 09:13:28 CDT 2017
Hello.
Sorry, but C# code:
interface IValidator<T> {
bool validate(T value);
}
IValidator<String> validator;
Easy, simple and clear.
Swift:
protocol PValidator {
associatedtype ValidateType
func validate(value: ValidateType) -> Bool
}
var validator: ????
it can be so:
var validator: PValidator where ValidateType == String
or
var validator: <T: PValidator> where ValidateType == String
or
var validator: PValidator<ValidateType == String>
or
typealias StringValidator = PValidator<ValidateType == String>
var validator: StringValidator
No matter how, but it should be.
What alternatives offers swift?
More information about the swift-evolution
mailing list