Ruby | Set include?() function Last Updated : 07 Jan, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report 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: It returns true if the set contains the given object or it returns false. Example 1: Ruby # Ruby program to illustrate # the include method # requires the set require "set" s1 = Set[16, 8, 3, 5, 2] # include method used puts s1.include?(2) Output: true Example 2: Ruby # Ruby program to illustrate # the include method # requires the set require "set" s1 = Set[1, 2, 3] # include method used puts s1.include?(5) Output: false Comment More infoAdvertise with us Next Article Ruby | Set include?() function G gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Set-class Similar Reads Ruby | Hash include?() function Hash#include?() is a Hash class method which checks whether the given key is present in hash. Syntax: Hash.include?() Parameter: Hash values Return: true - if given key"" is present in hash otherwise return false Example #1 : Ruby # Ruby code for Hash.has_value?() method # declaring Hash value a = { 2 min read Ruby | Range include?() function The include?() is an inbuilt method in Ruby returns a boolean value true if the given object lies within the given range, else it returns false. Syntax: range1.include?(obj) Parameters: The function accepts an object which is to be checked for. Return Value: It returns a boolean value true if the gi 1 min read Ruby | Set intersect?() function 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 gi 1 min read Ruby | Set replace() function The replace() is an inbuilt method in Ruby which replaces the contents of the set with the contents of the given enumerable object and returns self. Syntax: s1.replace(enum) Parameters: The function accepts an enumerable object which to be replaced in the set. Return Value: It returns the self objec 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 Like