require 'set' s = Set.new((1..10).collect) # Divide the set into the "0" subset and the "1" subset: that is, the # "even" subset and the "odd" subset. p s.divide { |x| x % 2 } # => #<Set: {#<Set: {6, 2, 8, 4, 10}>, #<Set: {5, 1, 7, 3, 9}>}>