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:
require "set"
s1 = Set[ 2 , 12 , 78 , 10 , 87 , 98 ]
puts s1.reset()
|
Output:
Set: {2, 12, 78, 10, 87, 98}
Example 2:
require "set"
s1 = Set[ 1 , 2 , 4 , 3 , 2 ]
puts s1.reset()
|
Output:
Set: {1, 2, 4, 3}
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...