require 'set' s = Set.new([1, 2, 3, 'a', 'b', 'c', -1.0, -2.0, -3.0]) # Divide the set into the "String subset, the "Fixnum" subset, and the # "Float" subset. p s.divide { |x| x.class } # => #<Set: {#<Set: {"a", "b", "c"}>, # => #<Set: {1, 2, 3}>, # => #<Set: {-1.0, -3.0, -2.0}>}>