Skip to content

Instantly share code, notes, and snippets.

@hachibeeDI
Created May 2, 2014 13:06
Show Gist options
  • Save hachibeeDI/0b05abc016e0a452bb82 to your computer and use it in GitHub Desktop.
Save hachibeeDI/0b05abc016e0a452bb82 to your computer and use it in GitHub Desktop.
papers = [80, 10, 20, 30, 71, 69, 100]
result = papers.reduce(
{passing: [], rejected: [], }
) do |boxes, paper|
if paper >= 70 then boxes[:passing] else boxes[:rejected] end << (paper)
boxes
end
p result
# => {:passing=>[80, 71, 100], :rejected=>[10, 20, 30, 69]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment