Generate from array : Generator « Development « Ruby






Generate from array


require 'generator'

l = ["junk1", 1, "junk2", 2, "junk3", "junk4", 3, "junk5"]

g = Generator.new(l)
g.next                                # => "junk1"
g.next                                # => 1
g.next                                # => "junk2"

 








Related examples in the same category

1.Generator based on regualr expression