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
The Enumerable#to_set method can accept a block like Enumerable#map and it will return a Set containing unique entries.
If the return value of #map (a) Doesn't need to include duplicates or (b) Needs to be an Array because the public interface of the method says it must be an Array, then we would expect appropriate tests to ensure this property holds.
If neither of these is the case, then a Set can often function just as well as an Array, and perhaps even better if the assumption is that there can be no duplicate entries.
The text was updated successfully, but these errors were encountered:
The
Enumerable#to_set
method can accept a block likeEnumerable#map
and it will return aSet
containing unique entries.If the return value of
#map
(a) Doesn't need to include duplicates or (b) Needs to be anArray
because the public interface of the method says it must be anArray
, then we would expect appropriate tests to ensure this property holds.If neither of these is the case, then a
Set
can often function just as well as anArray
, and perhaps even better if the assumption is that there can be no duplicate entries.The text was updated successfully, but these errors were encountered: