Skip to content

Instantly share code, notes, and snippets.

@mendesbarreto
Created July 1, 2016 14:56
Show Gist options
  • Select an option

  • Save mendesbarreto/f2415b4ff32e1588f15f2765b971b2a7 to your computer and use it in GitHub Desktop.

Select an option

Save mendesbarreto/f2415b4ff32e1588f15f2765b971b2a7 to your computer and use it in GitHub Desktop.
Swift Cool Generator
// 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