0001Addexamplestodisjointandintersect.patch
lib/set.rb  

240  240  
241  241 
# Returns true if the set and the given set have at least one 
242  242 
# element in common. 
243 
# 

244 
# e.g.: 

245 
# 

246 
# require 'set' 

247 
# Set[1, 2, 3].intersect? Set[4, 5] # => false 

248 
# Set[1, 2, 3].intersect? Set[3, 4] # => true 

243  249 
def intersect?(set) 
244  250 
set.is_a?(Set) or raise ArgumentError, "value must be a set" 
245  251 
if size < set.size 
...  ...  
251  257  
252  258 
# Returns true if the set and the given set have no element in 
253  259 
# common. This method is the opposite of +intersect?+. 
260 
# 

261 
# e.g.: 

262 
# 

263 
# require 'set' 

264 
# Set[1, 2, 3].disjoint? Set[3, 4] # => false 

265 
# Set[1, 2, 3].disjoint? Set[4, 5] # => true 

266  
254  267 
def disjoint?(set) 
255  268 
!intersect?(set) 
256  269 
end 
257 
 