Last active
February 3, 2018 22:59
-
-
Save jverkoey/24ca1fe9cfd76b93d879 to your computer and use it in GitHub Desktop.
Tuple enumeration
This file contains 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 characters
/** The returned generator will enumerate each value of the provided tuple. */ | |
func generatorForTuple(tuple: Any) -> AnyGenerator<Any> { | |
return anyGenerator(Mirror(reflecting: tuple).children.lazy.map { $0.value }.generate()) | |
} | |
// Blogged at http://design.featherless.software/enumerating-tuple-values-swift/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment