From: "trans (Thomas Sawyer)" Date: 2012-03-18T21:53:29+09:00 Subject: [ruby-core:43447] [ruby-trunk - Feature #4553] Add Set#pick and Set#pop Issue #4553 has been updated by trans (Thomas Sawyer). I would expect `Array#pick` to work too. Which then leads one to think Array might support the equivalent of `Set#pop` as well. But since Array already has `#pop` it's not really a good idea to reuse same term, although in the case of Set, `#pop` might be an alias for such method. So what might such methods be called then? Well, if we look at hand-dandy `facets/random`: https://github.com/rubyworks/facets/blob/master/lib/standard/facets/random.rb Looks like it uses #at_rand/#at_rand! and #pick/pick!, where #pick has the additional option of returning a random subset if a size is given as argument. ---------------------------------------- Feature #4553: Add Set#pick and Set#pop https://bugs.ruby-lang.org/issues/4553#change-24914 Author: adgar (Michael Edgar) Status: Assigned Priority: Low Assignee: knu (Akinori MUSHA) Category: Target version: =begin 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? =end -- http://bugs.ruby-lang.org/