Skip to content

Commit

Permalink
Merge pull request #2917 from osyoyu/array-sample-random-example
Browse files Browse the repository at this point in the history
Array#sample に random オプションを使う例を追加
  • Loading branch information
znz authored Nov 18, 2024
2 parents 551b912 + e374a32 commit bd832c8
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions refm/api/src/_builtin/Array
Original file line number Diff line number Diff line change
Expand Up @@ -2258,6 +2258,14 @@ p a.sample(3) #=> [1, 9, 3]
p a #=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
#@end

random [[c:SecureRandom]] などの乱数生成器を渡すことができます。

#@samplecode 例
require 'securerandom'
a = (1..10).to_a
p a.sample(random: SecureRandom) #=> 2
#@end

--- cycle(n=nil) {|obj| block } -> nil
#@since 1.9.1
--- cycle(n=nil) -> Enumerator
Expand Down

0 comments on commit bd832c8

Please sign in to comment.