Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

Ruby | Set reset() function

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

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
Last Updated : 07 Jan, 2020
Like Article
Save Article
Similar Reads