This page describes an operation in the collection pipeline pattern. For more context read:


Runs a function on each element and groups the elements by the result.

The group-by operation returns a hashmap keyed by the result of the supplied function

["bat", "it", "a", "the"].group_by{|s| s.size}
# => {3=>["bat", "the"], 2=>["it"], 1=>["a"]}
(group-by count ["bat" "it" "a" "the"])
;; => {3 ["bat" "the"], 2 ["it"], 1 ["a"]}

Since it naturally returns a hashmap, any downstream operations need to treat this map as a list of key-value pairs in order to continue the flow in the pipeline.