Skip to content

Instantly share code, notes, and snippets.

@alyraz
Created January 30, 2013 01:41
Show Gist options
  • Save alyraz/4669857 to your computer and use it in GitHub Desktop.
Save alyraz/4669857 to your computer and use it in GitHub Desktop.
###**Enumberable Method: .each_with_index**
**Class:** Array of people and a horse
**Method:** .each_with_index
**Block:** do |item, index|
if index.even?
item.dance
else
item.push_up(2)
end
end
**Result:** returns whatever you inputed, plus dancing and pushups
array = [ryan, horse, omar, nigel, basti, alyssa]
array.each_with_index do |item, index|
if index.even?
item.dance
else
item.push_up(2)
end
end
------------------------------------
@jfarmer
Copy link

jfarmer commented Jan 30, 2013

This was awesome. :)

@alyraz
Copy link
Author

alyraz commented Feb 10, 2013

Thanks! This was FUN
More theatrics, please.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment