るりまサーチ

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

別のキーワード

  1. array fill
  2. array sample
  3. array []
  4. array rindex
  5. array count

検索結果

<< < 1 2 3 4 ... > >>

Array#repeated_combination(n) -> Enumerator (36125.0)

サイズ n の重複組み合わせをすべて生成し、それを引数としてブロックを実行 します。

...ombination(1).to_a #=> [[1], [2], [3]]
a.repeated_combination(2).to_a #=> [[1,1],[1,2],[1,3],[2,2],[2,3],[3,3]]
a.repeated_combination(3).to_a #=> [[1,1,1],[1,1,2],[1,1,3],[1,2,2],[1,2,3],
# [1,3,3],[2,2,2],[2,2,3],[2,3,3],[3,3,3]]
a.repeated_combination(4).to_a...
...epeated_combination(0).to_a #=> [[]] # one combination of length 0
//}

ブロックが与えられた場合、作成した配列の各要素を引数としてブロックを実
行して self を返します。

//emlist[例][ruby]{
a = [1, 2, 3]
result = []
a.repeated_combination(3) {|e| result <...
...< e} # => [1,2,3]
result #=> [[1,1,1],[1,1,2],[1,1,3],[1,2,2],[1,2,3],
# [1,3,3],[2,2,2],[2,2,3],[2,3,3],[3,3,3]]
//}

@see Array#repeated_permutation, Array#combination...

Array#repeated_combination(n) { |c| ... } -> self (36125.0)

サイズ n の重複組み合わせをすべて生成し、それを引数としてブロックを実行 します。

...ombination(1).to_a #=> [[1], [2], [3]]
a.repeated_combination(2).to_a #=> [[1,1],[1,2],[1,3],[2,2],[2,3],[3,3]]
a.repeated_combination(3).to_a #=> [[1,1,1],[1,1,2],[1,1,3],[1,2,2],[1,2,3],
# [1,3,3],[2,2,2],[2,2,3],[2,3,3],[3,3,3]]
a.repeated_combination(4).to_a...
...epeated_combination(0).to_a #=> [[]] # one combination of length 0
//}

ブロックが与えられた場合、作成した配列の各要素を引数としてブロックを実
行して self を返します。

//emlist[例][ruby]{
a = [1, 2, 3]
result = []
a.repeated_combination(3) {|e| result <...
...< e} # => [1,2,3]
result #=> [[1,1,1],[1,1,2],[1,1,3],[1,2,2],[1,2,3],
# [1,3,3],[2,2,2],[2,2,3],[2,3,3],[3,3,3]]
//}

@see Array#repeated_permutation, Array#combination...

Array#repeated_permutation(n) -> Enumerator (36125.0)

サイズ n の重複順列をすべて生成し,それを引数としてブロックを実行します。

...rmutation(1).to_a #=> [[1], [2]]
a.repeated_permutation(2).to_a #=> [[1,1],[1,2],[2,1],[2,2]]
a.repeated_permutation(3).to_a #=> [[1,1,1],[1,1,2],[1,2,1],[1,2,2],
# [2,1,1],[2,1,2],[2,2,1],[2,2,2]]
a.repeated_permutation(0).to_a #=> [[]] # one permutation of le...
...ロックを実
行して self を返します。

//emlist[例][ruby]{
a = [1, 2]
result = []
a.repeated_permutation(3) {|e| result << e} # => [1,2]
result #=> [[1,1,1],[1,1,2],[1,2,1],[1,2,2],
# [2,1,1],[2,1,2],[2,2,1],[2,2,2]]
//}

@see Array#repeated_combination, Array#permutation...

Array#repeated_permutation(n) { |p| ... } -> self (36125.0)

サイズ n の重複順列をすべて生成し,それを引数としてブロックを実行します。

...rmutation(1).to_a #=> [[1], [2]]
a.repeated_permutation(2).to_a #=> [[1,1],[1,2],[2,1],[2,2]]
a.repeated_permutation(3).to_a #=> [[1,1,1],[1,1,2],[1,2,1],[1,2,2],
# [2,1,1],[2,1,2],[2,2,1],[2,2,2]]
a.repeated_permutation(0).to_a #=> [[]] # one permutation of le...
...ロックを実
行して self を返します。

//emlist[例][ruby]{
a = [1, 2]
result = []
a.repeated_permutation(3) {|e| result << e} # => [1,2]
result #=> [[1,1,1],[1,1,2],[1,2,1],[1,2,2],
# [2,1,1],[2,1,2],[2,2,1],[2,2,2]]
//}

@see Array#repeated_combination, Array#permutation...

Array#none? -> bool (36101.0)

ブロックを指定しない場合は、 配列のすべての 要素が偽であれば真を返します。そうでなければ偽を返します。

...none? {|word| word.length == 5} # => true
%w{ant bear cat}.none? {|word| word.length >= 4} # => false
%w{ant bear cat}.none?(/d/) # => true
[].none? # => true
[nil].none? # => true
[nil,false].none...
...? # => true
[nil, false, true].none? # => false
//}

@see Enumerable#none?...

絞り込み条件を変える

Array#none? {|obj| ... } -> bool (36101.0)

ブロックを指定しない場合は、 配列のすべての 要素が偽であれば真を返します。そうでなければ偽を返します。

...none? {|word| word.length == 5} # => true
%w{ant bear cat}.none? {|word| word.length >= 4} # => false
%w{ant bear cat}.none?(/d/) # => true
[].none? # => true
[nil].none? # => true
[nil,false].none...
...? # => true
[nil, false, true].none? # => false
//}

@see Enumerable#none?...

Array#none?(pattern) -> bool (36101.0)

ブロックを指定しない場合は、 配列のすべての 要素が偽であれば真を返します。そうでなければ偽を返します。

...none? {|word| word.length == 5} # => true
%w{ant bear cat}.none? {|word| word.length >= 4} # => false
%w{ant bear cat}.none?(/d/) # => true
[].none? # => true
[nil].none? # => true
[nil,false].none...
...? # => true
[nil, false, true].none? # => false
//}

@see Enumerable#none?...

Array#one? -> bool (36101.0)

ブロックを指定しない場合は、 配列の要素のうち ちょうど一つだけが真であれば、真を返します。 そうでなければ偽を返します。

...][ruby]{
%w{ant bear cat}.one? {|word| word.length == 4} # => true
%w{ant bear cat}.one? {|word| word.length > 4} # => false
%w{ant bear cat}.one?(/t/) # => false
[ nil, true, 99 ].one? # => false
[ nil, true, false ].one?...
...# => true
[ nil, true, 99 ].one?(Integer) # => true
[].one? # => false
//}

@see Enumerable#one?...

Array#one? {|obj| ... } -> bool (36101.0)

ブロックを指定しない場合は、 配列の要素のうち ちょうど一つだけが真であれば、真を返します。 そうでなければ偽を返します。

...][ruby]{
%w{ant bear cat}.one? {|word| word.length == 4} # => true
%w{ant bear cat}.one? {|word| word.length > 4} # => false
%w{ant bear cat}.one?(/t/) # => false
[ nil, true, 99 ].one? # => false
[ nil, true, false ].one?...
...# => true
[ nil, true, 99 ].one?(Integer) # => true
[].one? # => false
//}

@see Enumerable#one?...

Array#one?(pattern) -> bool (36101.0)

ブロックを指定しない場合は、 配列の要素のうち ちょうど一つだけが真であれば、真を返します。 そうでなければ偽を返します。

...][ruby]{
%w{ant bear cat}.one? {|word| word.length == 4} # => true
%w{ant bear cat}.one? {|word| word.length > 4} # => false
%w{ant bear cat}.one?(/t/) # => false
[ nil, true, 99 ].one? # => false
[ nil, true, false ].one?...
...# => true
[ nil, true, 99 ].one?(Integer) # => true
[].one? # => false
//}

@see Enumerable#one?...

絞り込み条件を変える

Array#dup -> Array (33205.0)

レシーバと同じ内容を持つ新しい配列を返します。

...レシーバと同じ内容を持つ新しい配列を返します。

clone は frozen singleton-class の情報も含めてコピーしますが、
dup は内容と tainted だけをコピーします。
またどちらのメソッドも要素それ自体のコピーはしません。
つまり...
...レシーバと同じ内容を持つ新しい配列を返します。

clone は frozen singleton-class の情報も含めてコピーしますが、
dup は内容だけをコピーします。
またどちらのメソッドも要素それ自体のコピーはしません。
つまり参照して...

Array#fetch(nth, ifnone) -> object (30125.0)

nth 番目の要素を返します。

...nth 番目の要素を返します。

Array
#[] (nth) とは nth 番目の要素が存在しない場合の振舞いが異
なります。最初の形式では、例外 IndexError が発生します。
二番目の形式では、引数 ifnone を返します。
三番目の形式では、ブロッ...
...@param ifnone 要素が存在しなかった場合に返すべき値を指定します。

@raise TypeError 引数 nth に整数以外の(暗黙の型変換が行えない)オブジェ
クトを指定した場合に発生します。

@raise IndexError 引数 ifnone もブロッ...
...なかった場合に発生します。

//emlist[例][ruby]{
a = [1, 2, 3, 4, 5]
begin
p a.fetch(10)
rescue IndexError => err
puts err #=> index 10 out of array
end

p a.fetch(10, 999) #=> 999

result = a.fetch(10){|nth|
print "#{nth} はありません。\n"
999
}
p result #=> 999
//}...
<< < 1 2 3 4 ... > >>