Ruby | Set reset() function
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 add? function
- Ruby | pop() function
- Ruby | at() function
- Ruby | reverse! function
- Ruby | Numeric div() function
- Ruby | Integer >= function
- Ruby | Matrix tr() function
- Ruby | Set merge() function
- Ruby | Range end() function
- Ruby | SizedQueue deq() function
- Ruby | Matrix t() function
- Ruby Integer odd? function with example
- Ruby Integer div() function with example
- Ruby | Time sec() 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.



