Last active
May 3, 2019 21:28
-
-
Save hcrub/e2aabc7959bb5c7c1b35ba8acd9e5f2a to your computer and use it in GitHub Desktop.
Revisions
-
hcrub revised this gist
May 3, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -13,7 +13,7 @@ extension Optional: OptionalType {} // The following example shows how you can use the `OptionalType` interface to scope // an extension containing an associated type defined as optional. E.g. `InputType??` protocol Validation { associatedType InputType } -
hcrub created this gist
May 3, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ /// Interface representing an optionally nil value type. protocol OptionalType: ExpressibleByNilLiteral { /// The boxed optional type. associatedtype Wrapped } extension Optional: OptionalType {} // Example // In this case, we have an extension that returns an optional type. // If the associated type is defined as optional, you will return a double optional. // The following example shows how you can use the `OptionalType` interface to scope // an extension containing an associated type defined as optional. E.g. `InputType??` interface Validation { associatedType InputType } // Returns `InputType?` extension Validation { func validate() -> InputType? {} } // Returns `InputType?` extension Validation: InputType { func validate() -> InputType {} }