Created
August 23, 2014 14:08
-
-
Save pyrtsa/ae8f7cdcfadbb12f35a1 to your computer and use it in GitHub Desktop.
Get the first value of sequence in Swift
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
func first<S: SequenceType>(xs: S) -> S.Generator.Element? { | |
var g = xs.generate() | |
return g.next() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment