Issue #4553 has been updated by Marc-Andre Lafortune.

Priority changed from Normal to Low

Hi.

There is no difference between your `Set#pick` and the existing `Set#first`. As such, there is no need for `pick`.

One can get the effect of `Set#pop` by calling the existing `Set#delete` with the result of `Set#first` (with the same O(1) efficiency).

 I find problematic that a method called `pop` would take the first element; it could be renamed to `shift`, say, or take the last element instead. More importantly, though, I am not convinced that this functionality is that frequently used.
----------------------------------------
Feature #4553: Add Set#pick and Set#pop
http://redmine.ruby-lang.org/issues/4553

Author: Michael Edgar
Status: Open
Priority: Low
Assignee: 
Category: 
Target version: 


A very common operation on sets is to take an arbitrary element from them at O(1) cost. I know typically
it's suggested that library additions go out as a gem to see community review. However, to me it seems
to be a glaring omission to lack such an operation on a built-in, fundamental data structure, so I've
gone straight to the bug tracker.

I wasn't too sure which method names to use as I've often heard "take" in lieu of "pop," so I just used the
names Wikipedia uses. Consider them flexible. "Pick" selects an arbitrary element, and "pop" selects and
deletes it.

I've provided a very simple patch that implements the necessary behavior. Thoughts?


-- 
http://redmine.ruby-lang.org