Ruby | Set intersect?() function Last Updated : 12 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report The intersect?() is an inbuilt method in Ruby returns true if the set and the given set have at least one element in common. Syntax: s1_name.intersect?(s2_name) Parameters: The function accepts a mandatory parameter set with whom it is checked for. Return Value: It returns true if the set and the given set have at least one element in common or else it returns false. Example 1: Ruby # Ruby program to illustrate # the intersect method # requires the set require "set" s1 = Set[16, 8, 3, 5, 2] s2 = Set[18, 17, 2] # intersect method used puts s1.intersect?(s2) Output: true Example 2: Ruby # Ruby program to illustrate # the intersect method # requires the set require "set" s1 = Set[16, 8] s2 = Set[18, 17, 56] # intersect method used puts s1.intersect?(s2) Output: false Comment More infoAdvertise with us Next Article Ruby | Vector independent? function G gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Set-class Similar Reads Ruby | Set intersection() function The intersection() is an inbuilt method in Ruby that returns a set which contains the common elements in both the set. In case there are no common elements, it returns an empty set. Syntax: s1.name.intersection(s2.name) Parameters: The function does not takes any parameter. Return Value: It returns 1 min read Ruby | Set include?() function The include?() is an inbuilt method in Ruby returns true if the set contains the given object. It returns false if it does not contains the given object. Syntax: s1_name.include?(object) Parameters: The function accepts a mandatory parameter object whose presence is to be checked for. Return Value: 1 min read Ruby | Set member?() function The member?() is an inbuilt method in Ruby returns true if the set contains the given object. It returns false if it does not contains the given object. Syntax: s1_name.member?(object) Parameters: The function accepts a mandatory parameter object whose presence is to be checked for. Return Value: It 1 min read Ruby | Set subset? function The subset?() is an inbuilt method in Ruby returns true if the set is a subset of the given set. Syntax: s1_name.subset?(s2_name) Parameters: The function takes a mandatory parameter with which it is ch Return Value: It returns self. Example 1: Ruby # Ruby program to illustrate # the subset?() metho 1 min read Ruby | Vector independent? function The independent? is an inbuilt method in Ruby returns true if given vectors are linearly independent otherwise false Syntax: Vector.independent?(vectors) Parameters: The function accepts vectors as parameter Return Value: It returns true if given vectors are linearly independent otherwise false. Exa 1 min read Ruby | Numeric zero? function The zero?() is an inbuilt method in Ruby returns a boolean value. It returns true if the number is a negative one, else it returns false. Syntax: num.zero?() Parameters: The function needs a number which is to be checked for. Return Value: It returns returns a boolean value. Example 1: CPP # Ruby pr 1 min read Like