From: nobu@... Date: 2016-09-20T06:03:24+00:00 Subject: [ruby-core:77321] [Ruby trunk Feature#12775][Feedback] Random subset of array Issue #12775 has been updated by Nobuyoshi Nakada. Status changed from Open to Feedback Do you mean random size subset? I can't get how/why it is useful. Please elaborate with the use cases. ---------------------------------------- Feature #12775: Random subset of array https://bugs.ruby-lang.org/issues/12775#change-60570 * Author: Tsuyoshi Sawada * Status: Feedback * Priority: Normal * Assignee: ---------------------------------------- I often see use cases to randomly sample a subset from an array like this: ```ruby a = [3, 2, 6, 2, 6, 1] a.sample(rand(a.length + 1)) # => [2, 6, 6, 3] ``` I request extending `Array#sample` to let it take an option (such as `:arbitrary`) for doing that: ```ruby a.sample(:arbitrary) # => [2, 6, 6, 3] ``` or perhaps having an independent method (like `samples`) to do it. ```ruby a.samples # => [2, 6, 6, 3] ``` -- https://bugs.ruby-lang.org/ Unsubscribe: