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?
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to