Skip to content

Instantly share code, notes, and snippets.

@mayfer
Created February 5, 2015 22:20
Show Gist options
  • Save mayfer/ffb839fd5bd24aa72ede to your computer and use it in GitHub Desktop.
Save mayfer/ffb839fd5bd24aa72ede to your computer and use it in GitHub Desktop.
Block example (re-writing select with puts)
def select(arr)
arr.each do |elem|
if yield elem
puts elem
end
end
end
select([1, 5, 7, 2, 4, 6]) do |elem|
elem % 2 == 1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment