Skip to content

Instantly share code, notes, and snippets.

Created Feb 6, 2017
What would you like to do?
ajudando o luiz a fazer group_by
a = [ {x: 'Abril/17', y: 10}, {x: 'Abril/17', y: 5}, {x: 'Abril/17', y: 2}, {x: 'Dezembro/17', y: 12}, ]
luiz = a.group_by{ |hash| hash[:x] }.map do |k,v|
{:x => k, :y =>{ |hash| hash[:y] }.inject(:+)}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment