Skip to content

Instantly share code, notes, and snippets.

@jredville
Created February 19, 2014 17:16
Show Gist options
  • Save jredville/9096707 to your computer and use it in GitHub Desktop.
Save jredville/9096707 to your computer and use it in GitHub Desktop.
def enumerable_select_with_index(arr, &block)
[].tap do |new_arr|
arr.each_with_index do |item, index|
new_arr.push item if block.call item, index
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment