るりまサーチ

最速Rubyリファレンスマニュアル検索!
84件ヒット [1-84件を表示] (0.094秒)

別のキーワード

  1. _builtin to_s
  2. openssl to_der
  3. openssl to_s
  4. _builtin to_a
  5. openssl to_pem

ライブラリ

クラス

検索結果

Array#sample -> object | nil (18147.0)

配列の要素を1個(引数を指定した場合は自身の要素数を越えない範囲で n 個) ランダムに選んで返します。

...値を指定した場合は要素数と同じ数の配列を返します。
整数以外のオブジェクトを指定した場合は to_int メソッドによる暗
黙の型変換を試みます。

@param random 乱数生成器(主に Random オブジェクト)を指定し...
...うに選択可能なイン
デックスの最大値が指定されます。
Kernel
.#rand、Random を使用しないオブジェク
トを指定した場合、Kernel.#srandの指定に影響されません。

@raise TypeError 引数 n に整数以外の(...
..._a
p a.sample #=> 9
p a.sample #=> 10
p a.sample(3) #=> [1, 9, 3]
p a #=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
//}

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

//emlist[例][ruby]{
require 'securerandom'
a = (1..10).to_a
p a.sample(rando...

Array#sample(n) -> Array (18147.0)

配列の要素を1個(引数を指定した場合は自身の要素数を越えない範囲で n 個) ランダムに選んで返します。

...値を指定した場合は要素数と同じ数の配列を返します。
整数以外のオブジェクトを指定した場合は to_int メソッドによる暗
黙の型変換を試みます。

@param random 乱数生成器(主に Random オブジェクト)を指定し...
...うに選択可能なイン
デックスの最大値が指定されます。
Kernel
.#rand、Random を使用しないオブジェク
トを指定した場合、Kernel.#srandの指定に影響されません。

@raise TypeError 引数 n に整数以外の(...
..._a
p a.sample #=> 9
p a.sample #=> 10
p a.sample(3) #=> [1, 9, 3]
p a #=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
//}

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

//emlist[例][ruby]{
require 'securerandom'
a = (1..10).to_a
p a.sample(rando...

Array#sample(n, random: Random) -> Array (18147.0)

配列の要素を1個(引数を指定した場合は自身の要素数を越えない範囲で n 個) ランダムに選んで返します。

...値を指定した場合は要素数と同じ数の配列を返します。
整数以外のオブジェクトを指定した場合は to_int メソッドによる暗
黙の型変換を試みます。

@param random 乱数生成器(主に Random オブジェクト)を指定し...
...うに選択可能なイン
デックスの最大値が指定されます。
Kernel
.#rand、Random を使用しないオブジェク
トを指定した場合、Kernel.#srandの指定に影響されません。

@raise TypeError 引数 n に整数以外の(...
..._a
p a.sample #=> 9
p a.sample #=> 10
p a.sample(3) #=> [1, 9, 3]
p a #=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
//}

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

//emlist[例][ruby]{
require 'securerandom'
a = (1..10).to_a
p a.sample(rando...

Array#sample(random: Random) -> object | nil (18147.0)

配列の要素を1個(引数を指定した場合は自身の要素数を越えない範囲で n 個) ランダムに選んで返します。

...値を指定した場合は要素数と同じ数の配列を返します。
整数以外のオブジェクトを指定した場合は to_int メソッドによる暗
黙の型変換を試みます。

@param random 乱数生成器(主に Random オブジェクト)を指定し...
...うに選択可能なイン
デックスの最大値が指定されます。
Kernel
.#rand、Random を使用しないオブジェク
トを指定した場合、Kernel.#srandの指定に影響されません。

@raise TypeError 引数 n に整数以外の(...
..._a
p a.sample #=> 9
p a.sample #=> 10
p a.sample(3) #=> [1, 9, 3]
p a #=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
//}

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

//emlist[例][ruby]{
require 'securerandom'
a = (1..10).to_a
p a.sample(rando...

Random#rand -> Float (43.0)

一様な擬似乱数を発生させます。

...様です。
このため range が Time の場合などにもうまく動作します。

引数が実数でも範囲でもない場合は Object#to_int で変換した値が指定されたものとして扱います。

@param max 乱数値の上限を正の整数または実数で指定しま...
...に負の数値を与えた時や (1..0) のような値が存在しない範囲を渡した時などに発生します。

//emlist[例][ruby]{
# Kernel.#rand とほぼ同様の使い勝手
prng = Random.new(1234)
prng.rand # => 0.1915194503788923
srand(1234)
rand # => 0....
...-25 03:11:42 +0900
require 'date'
prng.rand(Date.new(2012, 1, 1) ... Date.new(2013,1,1)) # => #<Date: 2012-01-31 ((2455958j,0s,0n),+0s,2299161j)>
# Kernel.#rand とほぼ同様の使い勝手
prng = Random.new(1234)
prng.rand # => 0.1915194503788923
srand(1234)
rand # => 0...

絞り込み条件を変える

Random#rand(max) -> Integer | Float (43.0)

一様な擬似乱数を発生させます。

...様です。
このため range が Time の場合などにもうまく動作します。

引数が実数でも範囲でもない場合は Object#to_int で変換した値が指定されたものとして扱います。

@param max 乱数値の上限を正の整数または実数で指定しま...
...に負の数値を与えた時や (1..0) のような値が存在しない範囲を渡した時などに発生します。

//emlist[例][ruby]{
# Kernel.#rand とほぼ同様の使い勝手
prng = Random.new(1234)
prng.rand # => 0.1915194503788923
srand(1234)
rand # => 0....
...-25 03:11:42 +0900
require 'date'
prng.rand(Date.new(2012, 1, 1) ... Date.new(2013,1,1)) # => #<Date: 2012-01-31 ((2455958j,0s,0n),+0s,2299161j)>
# Kernel.#rand とほぼ同様の使い勝手
prng = Random.new(1234)
prng.rand # => 0.1915194503788923
srand(1234)
rand # => 0...

Random#rand(range) -> Integer | Float (43.0)

一様な擬似乱数を発生させます。

...様です。
このため range が Time の場合などにもうまく動作します。

引数が実数でも範囲でもない場合は Object#to_int で変換した値が指定されたものとして扱います。

@param max 乱数値の上限を正の整数または実数で指定しま...
...に負の数値を与えた時や (1..0) のような値が存在しない範囲を渡した時などに発生します。

//emlist[例][ruby]{
# Kernel.#rand とほぼ同様の使い勝手
prng = Random.new(1234)
prng.rand # => 0.1915194503788923
srand(1234)
rand # => 0....
...-25 03:11:42 +0900
require 'date'
prng.rand(Date.new(2012, 1, 1) ... Date.new(2013,1,1)) # => #<Date: 2012-01-31 ((2455958j,0s,0n),+0s,2299161j)>
# Kernel.#rand とほぼ同様の使い勝手
prng = Random.new(1234)
prng.rand # => 0.1915194503788923
srand(1234)
rand # => 0...