jweinst1
2/24/2016 - 10:11 PM

a number generator in swift

a number generator in swift

struct numgenerator {
    var current:Int
    var increment:Int
    
    init(increment:Int=1, start:Int=0) {
        self.current = start
        self.increment = increment
    }
    
    mutating func next() ->Int {
        let yield = self.current
        self.current += self.increment
        return yield
    }
}