From 4894a1eb35823bdfea4ca000ca08d0fe3b27a574 Mon Sep 17 00:00:00 2001 From: BurdetteLamar Date: Thu, 18 Dec 2025 18:42:33 +0000 Subject: [PATCH] [DOC] Doc for #& --- lib/set.rb | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/set.rb b/lib/set.rb index ad04b85..cf6051e 100644 --- a/lib/set.rb +++ b/lib/set.rb @@ -638,11 +638,16 @@ def -(enum) end alias difference - - # Returns a new set containing elements common to the set and the - # given enumerable object. + # :call-seq: + # self & object -> new_set + # + # Returns a new set containing elements found both in +self+ + # and in +object+, which must be an array: + # + # s = [0, 'a', :foo, 1, 'b', :bar] + # s & [0, 'b', 1, :bar] # => [0, 1, "b", :bar] + # s & [2, 'c'] # => [] # - # Set[1, 3, 5] & Set[3, 2, 1] #=> # - # Set['a', 'b', 'z'] & ['a', 'b', 'c'] #=> # def &(enum) n = self.class.new if enum.is_a?(Set)