From 9972d13a4ece8b85c515f02d818baae9351f4249 Mon Sep 17 00:00:00 2001 From: Mathew Polzin Date: Mon, 21 Jan 2019 15:37:41 -0800 Subject: [PATCH] Document zip(with:) on optionals --- Sources/JSONAPIOpenAPI/Optional+ZipWith.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Sources/JSONAPIOpenAPI/Optional+ZipWith.swift b/Sources/JSONAPIOpenAPI/Optional+ZipWith.swift index cbe113e..b04b7c2 100644 --- a/Sources/JSONAPIOpenAPI/Optional+ZipWith.swift +++ b/Sources/JSONAPIOpenAPI/Optional+ZipWith.swift @@ -5,6 +5,9 @@ // Created by Mathew Polzin on 1/19/19. // +/// Zip two optionals together with the given operation performed on +/// the unwrapped contents. If either optional is nil, the zip +/// yields nil. func zip(_ left: X?, _ right: Y?, with fn: (X, Y) -> Z) -> Z? { return left.flatMap { lft in right.map { rght in fn(lft, rght) }} }