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() |
chevron_right
filter_none
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() |
chevron_right
filter_none
Output:
Set: {1, 2, 4, 3}
Recommended Posts:
- Ruby | StringScanner reset function
- Ruby | Set replace() function
- Ruby | Set merge() function
- Ruby | Set member?() function
- Ruby | Set include?() function
- Ruby | Set delete? function
- Ruby | Set delete() function
- Ruby | Set compare_by_identity? function
- Ruby | Set compare_by_identity() function
- Ruby | Set add? function
- Ruby | Set clear() function
- Ruby | Set difference() function
- Ruby | Set disjoint? function
- Ruby | Set flatten() function
- Ruby | Set flatten!() function
- Ruby | Set intersect?() function
- Ruby | Set intersection() function
- Ruby | Set length() function
- Ruby | Set size() function
- Ruby | Set proper_subset?() function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

