Project

General

Profile

Misc #9331 ยป 0001-Add-examples-to-disjoint-and-intersect.patch

lkdjiin (xavier nayrac), 12/31/2013 05:37 PM

View differences:

lib/set.rb
# Returns true if the set and the given set have at least one
# element in common.
#
# e.g.:
#
# require 'set'
# Set[1, 2, 3].intersect? Set[4, 5] # => false
# Set[1, 2, 3].intersect? Set[3, 4] # => true
def intersect?(set)
set.is_a?(Set) or raise ArgumentError, "value must be a set"
if size < set.size
......
# Returns true if the set and the given set have no element in
# common. This method is the opposite of +intersect?+.
#
# e.g.:
#
# require 'set'
# Set[1, 2, 3].disjoint? Set[3, 4] # => false
# Set[1, 2, 3].disjoint? Set[4, 5] # => true
def disjoint?(set)
!intersect?(set)
end
    (1-1/1)