るりまサーチ

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

別のキーワード

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

検索結果

<< 1 2 3 ... > >>

Array#to_a -> Array (39288.0)

self を返します。ただし、Array のサブクラスのインスタンスに対して呼ばれた時は、 自身を Array に変換したものを返します。

...し、Array のサブクラスのインスタンスに対して呼ばれた時は、
自身を Array に変換したものを返します。

//emlist[例][ruby]{
class SubArray < Array; end
ary1 = Array([1, 2, 3, 4])
ary2 = SubArray([1, 2, 3, 4])

ary1.to_a # => [1, 2, 3, 4]
ary1.to_a.class...
...# => Array

ary2.to_a # => [1, 2, 3, 4]
ary2.to_a.class # => Array
//}

@see Array#to_ary...

Array#to_ary -> self (27130.0)

self をそのまま返します。

...をそのまま返します。

//emlist[例][ruby]{
class SubArray < Array; end
ary1 = Array([1, 2, 3, 4])
ary2 = SubArray([1, 2, 3, 4])

ary1.to_ary # => [1, 2, 3, 4]
ary1.to_ary.class # => Array

ary2.to_ary # => [1, 2, 3, 4]
ary2.to_ary.class # => SubArray
//}

@see Array#to_a...

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

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

...した場合に発生します。

@raise ArgumentError 引数 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]
//}...

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

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

...した場合に発生します。

@raise ArgumentError 引数 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]
//}...

Array#combination(n) -> Enumerator (21048.0)

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

...mbination(1).to_a #=> [[1],[2],[3],[4]]
a.combination(2).to_a #=> [[1,2],[1,3],[1,4],[2,3],[2,4],[3,4]]
a.combination(3).to_a #=> [[1,2,3],[1,2,4],[1,3,4],[2,3,4]]
a.combination(4).to_a #=> [[1,2,3,4]]
a.combination(0).to_a #=> [[]]: one combination of length 0
a.combination(5).to_a #=> [] :...
...た配列の各要素を引数としてブロックを実
行して self を返します。

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

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

絞り込み条件を変える

Array#combination(n) {|c| block } -> self (21048.0)

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

...mbination(1).to_a #=> [[1],[2],[3],[4]]
a.combination(2).to_a #=> [[1,2],[1,3],[1,4],[2,3],[2,4],[3,4]]
a.combination(3).to_a #=> [[1,2,3],[1,2,4],[1,3,4],[2,3,4]]
a.combination(4).to_a #=> [[1,2,3,4]]
a.combination(0).to_a #=> [[]]: one combination of length 0
a.combination(5).to_a #=> [] :...
...た配列の各要素を引数としてブロックを実
行して self を返します。

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

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

Array#permutation(n = self.length) -> Enumerator (21048.0)

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

...3]
a.permutation.to_a #=> [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]
a.permutation(1).to_a #=> [[1],[2],[3]]
a.permutation(2).to_a #=> [[1,2],[1,3],[2,1],[2,3],[3,1],[3,2]]
a.permutation(3).to_a #=> [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]
a.permutation(0).to_a #=> [[]]: one...
...permutation of length 0
a.permutation(4).to_a #=> [] : no permutations of length 4
//}

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

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

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

Array#permutation(n = self.length) { |p| block } -> self (21048.0)

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

...3]
a.permutation.to_a #=> [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]
a.permutation(1).to_a #=> [[1],[2],[3]]
a.permutation(2).to_a #=> [[1,2],[1,3],[2,1],[2,3],[3,1],[3,2]]
a.permutation(3).to_a #=> [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]
a.permutation(0).to_a #=> [[]]: one...
...permutation of length 0
a.permutation(4).to_a #=> [] : no permutations of length 4
//}

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

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

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

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

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

...ion(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 #=> [...
...2],[1,2,2,3],[1,2,3,3],[1,3,3,3],
# [2,2,2,2],[2,2,2,3],[2,2,3,3],[2,3,3,3],[3,3,3,3]]
a.repeated_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 (21042.0)

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

...ion(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 #=> [...
...2],[1,2,2,3],[1,2,3,3],[1,3,3,3],
# [2,2,2,2],[2,2,2,3],[2,2,3,3],[2,3,3,3],[3,3,3,3]]
a.repeated_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...

絞り込み条件を変える

<< 1 2 3 ... > >>