Skip to content

Instantly share code, notes, and snippets.

@carllerche
Created October 28, 2009 06:54
Show Gist options
  • Save carllerche/220304 to your computer and use it in GitHub Desktop.
Save carllerche/220304 to your computer and use it in GitHub Desktop.
def matching(prop)
@matching ||= inject({}) do |hash, p|
(hash[p.root] ||= []) << p
hash
end[prop.root] || []
end
def matching(prop)
@matching ||= begin
map = {}
each do |p|
map[p.root] ||= []
map[p.root] << p
end
map
end
@matching[prop.root] || []
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment