From e374a320a1ad6fad51cd00a9a71e43f1515e362b Mon Sep 17 00:00:00 2001 From: Daisuke Aritomo Date: Sat, 9 Nov 2024 16:57:24 +0900 Subject: [PATCH] =?UTF-8?q?Array#sample=20=E3=81=AB=20random=20=E3=82=AA?= =?UTF-8?q?=E3=83=97=E3=82=B7=E3=83=A7=E3=83=B3=E3=82=92=E4=BD=BF=E3=81=86?= =?UTF-8?q?=E4=BE=8B=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- refm/api/src/_builtin/Array | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/refm/api/src/_builtin/Array b/refm/api/src/_builtin/Array index d00beb672d..9c75a71615 100644 --- a/refm/api/src/_builtin/Array +++ b/refm/api/src/_builtin/Array @@ -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