Skip to content

Instantly share code, notes, and snippets.

@alloy-d
Created September 26, 2013 20:13
Show Gist options
  • Save alloy-d/6719878 to your computer and use it in GitHub Desktop.
Save alloy-d/6719878 to your computer and use it in GitHub Desktop.
A hacky method for classifying things based on user input.
classify = ->(list, ider) do
groups = {}
list.each do |thing|
print "#{ider.call(thing)} "
(groups[gets.chomp.intern]||=[]) << thing
end
groups
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment