236件ヒット
[1-100件を表示]
(0.038秒)
別のキーワード
クラス
-
ARGF
. class (72) - Array (72)
- Module (28)
- Object (36)
- SystemExit (12)
- Thread (12)
モジュール
- Warning (4)
キーワード
-
alias
_ method (4) -
class
_ variables (12) - constants (12)
-
instance
_ variables (12) - raise (12)
- readlines (36)
- sample (48)
- shuffle! (24)
- status (12)
-
to
_ a (48) -
to
_ ary (12) - warn (4)
検索結果
先頭5件
-
Object
# to _ ary -> Array (6209.0) -
オブジェクトの Array への暗黙の変換が必要なときに内部で呼ばれます。 デフォルトでは定義されていません。
...オブジェクトの Array への暗黙の変換が必要なときに内部で呼ばれます。
デフォルトでは定義されていません。
説明のためここに記載してありますが、
このメソッドは実際には Object クラスには定義されていません。
必要......すべての場面で代置可能であるような、
* 配列そのものとみなせるようなもの
という厳しいものになっています。
//emlist[][ruby]{
class Foo
def to_ary
[3,4]
end
end
it = Foo.new
p([1,2] + it) #=> [1, 2, 3, 4]
//}
@see Object#to_a,Kernel.#Array... -
Array
# sample(n) -> Array (3115.0) -
配列の要素を1個(引数を指定した場合は自身の要素数を越えない範囲で n 個) ランダムに選んで返します。
...デックスの最大値が指定されます。
Kernel.#rand、Random を使用しないオブジェク
トを指定した場合、Kernel.#srandの指定に影響されません。
@raise TypeError 引数 n に整数以外の(暗黙の型変換が行え......//emlist[例][ruby]{
a = (1..10).to_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 'securerand... -
Array
# sample(n , random: Random) -> Array (3115.0) -
配列の要素を1個(引数を指定した場合は自身の要素数を越えない範囲で n 個) ランダムに選んで返します。
...デックスの最大値が指定されます。
Kernel.#rand、Random を使用しないオブジェク
トを指定した場合、Kernel.#srandの指定に影響されません。
@raise TypeError 引数 n に整数以外の(暗黙の型変換が行え......//emlist[例][ruby]{
a = (1..10).to_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 'securerand... -
Array
# sample -> object | nil (3015.0) -
配列の要素を1個(引数を指定した場合は自身の要素数を越えない範囲で n 個) ランダムに選んで返します。
...デックスの最大値が指定されます。
Kernel.#rand、Random を使用しないオブジェク
トを指定した場合、Kernel.#srandの指定に影響されません。
@raise TypeError 引数 n に整数以外の(暗黙の型変換が行え......//emlist[例][ruby]{
a = (1..10).to_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 'securerand... -
Array
# sample(random: Random) -> object | nil (3015.0) -
配列の要素を1個(引数を指定した場合は自身の要素数を越えない範囲で n 個) ランダムに選んで返します。
...デックスの最大値が指定されます。
Kernel.#rand、Random を使用しないオブジェク
トを指定した場合、Kernel.#srandの指定に影響されません。
@raise TypeError 引数 n に整数以外の(暗黙の型変換が行え......//emlist[例][ruby]{
a = (1..10).to_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 'securerand... -
Array
# shuffle! -> self (3015.0) -
配列を破壊的にランダムシャッフルします。
...デックスの最大値が指定されます。
Kernel.#rand、Random を使用しないオブジェク
トを指定した場合、Kernel.#srandの指定に影響されま
せん。
//emlist[例][ruby]{
a = [ 1, 2, 3 ] #=> [1, 2, 3]
a.shuffle......! #=> [2, 3, 1]
a #=> [2, 3, 1]
//}
@see Array#shuffle... -
Array
# shuffle!(random: Random) -> self (3015.0) -
配列を破壊的にランダムシャッフルします。
...デックスの最大値が指定されます。
Kernel.#rand、Random を使用しないオブジェク
トを指定した場合、Kernel.#srandの指定に影響されま
せん。
//emlist[例][ruby]{
a = [ 1, 2, 3 ] #=> [1, 2, 3]
a.shuffle......! #=> [2, 3, 1]
a #=> [2, 3, 1]
//}
@see Array#shuffle... -
SystemExit
# status -> Integer (3009.0) -
例外オブジェクトに保存された終了ステータスを返します。
...を返します。
終了ステータスは Kernel.#exit や SystemExit.new などで設定されます。
例:
begin
exit 1
rescue SystemExit => err
p err.status # => 1
end
begin
raise SystemExit.new(1, "dummy exit")
rescue SystemExit => err
p err.status # => 1
e... -
Thread
# raise(error _ type , message , traceback) -> () (121.0) -
自身が表すスレッドで強制的に例外を発生させます。
...が表すスレッドで強制的に例外を発生させます。
@param error_type Kernel.#raise を参照してください。
@param message Kernel.#raise を参照してください。
@param traceback Kernel.#raise を参照してください。
Thread.new {
sleep 1
Thread.main.r...