Mega Code Archive
Categories
/
Ruby
/
Collections
Divide a set by even and odd value
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 } # => #
, #
}>