Ruby | Set empty?() function Last Updated : 07 Jan, 2020 Comments Improve Suggest changes Like Article Like Report The empty?() is an inbuilt method in Ruby returns true if the set is empty or it returns false. Syntax: s1.empty?() Parameters: The function does not takes any parameter. Return Value: It returns a boolean value. It returns true if the set is empty or it returns false. Example 1: Ruby # Ruby program to illustrate the empty method # requires the set require "set" s1 = Set[] # empty method used puts "is empty?:" puts s1.empty?() Output: is empty?: true Example 2: Ruby # Ruby program to illustrate the empty method # requires the set require "set" s1 = Set[16, 8, 3, 5, 2] # empty method used puts "is empty?:" puts s1.empty?() Output: false Comment More infoAdvertise with us Next Article Ruby | Set empty?() function G gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Set-class Similar Reads Ruby | Symbol empty? function Symbol#empty?() : empty?() is a Symbol class method which checks whether the symbol is empty. Syntax: Symbol.empty?() Parameter: Symbol values Return: true - if symbol is empty otherwise return false Example #1 : Ruby # Ruby code for Symbol.empty?() method # declaring Symbol a = :aBcDeF # declaring 2 min read Ruby | Set delete? function The delete?() is an inbuilt method in Ruby which deletes the given object from the set and returns the self object. In case the object is not present, it returns nil. Syntax: s1.name.delete(object) Parameters: The function takes a mandatory parameter object which is to be deleted. Return Value: It r 1 min read Ruby | SizedQueue empty? function The empty? is an inbuilt function in Ruby checks if the SizedQueue is empty or not?. It returns a boolean value, which is true if the SizedQueue is empty or it returns false. Empty here means if it contains elements or not in it. Syntax: sq_name.empty? Parameters: The function does not takes any ele 1 min read Ruby | Set clear() function The clear() is an inbuilt method in Ruby which clears all the elements in the set. Syntax: s1.name.clear() Parameters: The function does not takes any parameter. Return Value: It returns self after clearing all the elements in the set. Example 1: CPP #Ruby program to illustrate the clear method #req 1 min read Ruby | Set add? function The add? is an inbuilt method in Ruby which adds the given object to the set and returns self. If the object is already in the set, returns nil. Syntax: s1.name.add?(object) Parameters: The function takes the object to be added to the set. Return Value: It returns self if the object is not in the se 1 min read Like