Skip to content

Instantly share code, notes, and snippets.

@RoxasShadow
Created October 26, 2012 19:06
Show Gist options
  • Save RoxasShadow/3960782 to your computer and use it in GitHub Desktop.
Save RoxasShadow/3960782 to your computer and use it in GitHub Desktop.
select_with_index
module Enumerable
def select_with_index
i = 0
self.select { |e|
i += 1
yield e, i
}
end
end
ary = *(?a..?z)
len = ary.length
ary.select_with_index { |e, i| puts e if i == len / 2 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment