Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //MARK: Create Specifications
- protocol Specification {
- associatedtype T
- func isSatisfied(item: T) -> Bool
- }
- struct ColorSpecification: Specification {
- typealias T = Product
- var color: Color
- func isSatisfied(item: Product) -> Bool {
- return item.color == color
- }
- }
- struct SizeSpecification: Specification {
- typealias T = Product
- var size: Size
- func isSatisfied(item: Product) -> Bool {
- return item.size == size
- }
- }
Add Comment
Please, Sign In to add comment