Skip to content

Instantly share code, notes, and snippets.

@julioterra
Created October 5, 2011 18:21
Show Gist options
  • Select an option

  • Save julioterra/1265228 to your computer and use it in GitHub Desktop.

Select an option

Save julioterra/1265228 to your computer and use it in GitHub Desktop.
creating an enumerator with the Enumerator.new method
enum_ingredients = Enumerator.new do |yielder|
ingredients = ["tomato", "arugula", "garlic", "olive oil", "balsamic", "parmesan"]
ingredients.each { |ingredient| yielder << ingredient }
end
enum_ingredients.each {|n| puts n}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment