Created
July 1, 2016 14:56
-
-
Save mendesbarreto/f2415b4ff32e1588f15f2765b971b2a7 to your computer and use it in GitHub Desktop.
Swift Cool Generator
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 characters
| // Coolest class ever | |
| class CoolGenerator: GeneratorType { | |
| typealias Element = String | |
| let collCount: Int | |
| private var count: Int = 0 | |
| init( collCount: Int ) { | |
| self.collCount = collCount | |
| } | |
| //Generates cool string | |
| func next() -> Element? { | |
| count += 1 | |
| if count <= collCount { | |
| return "😎" | |
| } | |
| return nil | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment