Skip to content
Related Articles

Related Articles

Ruby | Set reset() function
  • Last Updated : 07 Jan, 2020

The reset() is an inbuilt method in Ruby resets the internal state after modification to existing elements and returns self. The elements will be reindexed and deduplicated.

Syntax: s1.reset()

Parameters: The function does not accepts any parameter.

Return Value: It returns self .

Example 1:






# Ruby program to illustrate 
# the reset() method 
   
# requires the set 
require "set"
   
s1 = Set[2, 12, 78, 10, 87, 98
   
# reset method used 
puts s1.reset()

Output:

Set: {2, 12, 78, 10, 87, 98}

Example 2:




# Ruby program to illustrate 
# the reset() method 
   
# requires the set 
require "set"
   
s1 = Set[1, 2, 4, 3, 2
   
# reset method used 
puts s1.reset()

Output:

Set: {1, 2, 4, 3}
My Personal Notes arrow_drop_up
Recommended Articles
Page :