You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 19, 2018. It is now read-only.
classCountedSet# CountedSet works like a set but if keeps track of how many times the item as been added to the setdefset@set ||= Hash.new{ |h,k| h[k]=0}end# use mutator to define methods that mutate the object's instance datamutator:<<do |item|
set[item] += 1enddefto_aset.keysend
... etcend
# for preexisting classes you can just give mutator a list of the method names that are mutatorsHash.mutator:[],:delete, ... etc ... listallthemethodsthatmutatetheunderlyingstate.
So the catch is we have to send mutator to all the base classes that have mutable operations. However once it's done it's done