Sign up
Sign in
module Enumerable def tally(&function) function ||= -> v { v } each_with_object(Hash.new(0)) do |value, hash| hash[function.call(value)] += 1 end endend
Brandon Weaver
Dmitry Shvetsov
Follow
--
Share
Lovely! Looks so functional.
Software Engineer, Instructor, and Mentor. Author https://gum.co/team-lead-101. Join my newsletter https://gift.dmitryshvetsov.com/
Help
Status
About
Careers
Press
Blog
Privacy
Terms
Text to speech
Teams