Skip to content

Instantly share code, notes, and snippets.

@btedev
Forked from gstark/gist:2594974
Created May 4, 2012 14:05
Show Gist options
  • Save btedev/2594982 to your computer and use it in GitHub Desktop.
Save btedev/2594982 to your computer and use it in GitHub Desktop.
# Hash keyed by y to speed to_s
def to_h
hash_with_default = Hash.new {|hash,key| hash[key] = []}
@points.inject(hash_with_default) { |hash, point| h[point.y] << point.x; hash }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment