Skip to content

Instantly share code, notes, and snippets.

@gstark
Created May 4, 2012 14:02
Show Gist options
  • Save gstark/2594974 to your computer and use it in GitHub Desktop.
Save gstark/2594974 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