Skip to content

Instantly share code, notes, and snippets.

@voxxit
Created September 14, 2010 19:03
Show Gist options
  • Save voxxit/579570 to your computer and use it in GitHub Desktop.
Save voxxit/579570 to your computer and use it in GitHub Desktop.
def each_even_element(array)
i = 0
while i < array.length
yield array[i] if i % 2 == 1
i += 1
end
end
a = 1..1000.to_a
each_even_element(a) { |x| puts x }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment