1092件ヒット
[1-100件を表示]
(0.032秒)
種類
- インスタンスメソッド (1080)
- 特異メソッド (12)
キーワード
- & (12)
- * (24)
- + (12)
- - (12)
- <=> (12)
- [] (36)
- []= (36)
- at (12)
- bsearch (12)
-
bsearch
_ index (10) - collect (19)
- collect! (12)
- combination (24)
- cycle (24)
-
delete
_ at (12) -
delete
_ if (12) -
drop
_ while (12) - each (12)
-
each
_ index (12) - fetch (36)
- filter (7)
- filter! (7)
-
find
_ index (12) - first (24)
- flatten (12)
- flatten! (12)
- index (12)
- insert (12)
- inspect (12)
- intersection (6)
- join (12)
-
keep
_ if (12) - last (24)
- map (19)
- map! (12)
- pack (21)
- permutation (24)
- pop (24)
- reject (12)
- reject! (12)
-
repeated
_ combination (24) -
repeated
_ permutation (24) - replace (12)
-
reverse
_ each (12) - rindex (12)
- rotate (12)
- rotate! (12)
- sample (48)
- select (12)
- select! (12)
- shift (24)
- sort (24)
- sort! (24)
-
sort
_ by! (12) -
take
_ while (12) -
to
_ a (12) -
to
_ ary (12) -
to
_ csv (12) -
to
_ h (19) -
to
_ s (12) -
try
_ convert (12) - uniq (24)
- uniq! (24)
-
values
_ at (12) - zip (24)
- | (12)
検索結果
先頭5件
-
Array
# to _ csv(**options) -> String (6138.0) -
CSV.generate_line(self, options) と同様です。
...同様です。
Array オブジェクトを 1 行の CSV 文字列に変換するためのショートカットです。
@param options CSV.generate_line と同様のオプションを指定します。
//emlist[][ruby]{
require 'csv'
p [1, 'Matz', :Ruby, Date.new(1965, 4, 14)].to_csv......65, 4, 14)].to_csv(col_sep: ' ', row_sep: "\r\n") # => "1 Matz Ruby 1965-04-14\r\n"
//}
Ruby 3.0 (CSV 3.1.9) から、次のオプションが使えるようになりました。
//emlist[][ruby]{
require 'csv'
puts [1, nil].to_csv # => 1,
puts [1, nil].to_csv(write_n......il_value: "N/A") # => 1,N/A
puts [2, ""].to_csv # => 2,""
puts [2, ""].to_csv(write_empty_value: "BLANK") # => 2,BLANK
//}
@see CSV.generate_line... -
Array
# to _ a -> Array (6132.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 (6132.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
# to _ h -> Hash (6115.0) -
self を [key, value] のペアの配列として解析した結果を Hash にして 返します。
...//emlist[例][ruby]{
bar], [1, 2.to_h # => {:foo => :bar, 1 => 2}
//}
ブロックを指定すると配列の各要素でブロックを呼び出し、
その結果をペアとして使います。
//emlist[ブロック付きの例][ruby]{
["foo", "bar"].to_h {|s| [s.ord, s]} # => {102=>"foo", 9... -
Array
# to _ h { block } -> Hash (6115.0) -
self を [key, value] のペアの配列として解析した結果を Hash にして 返します。
...//emlist[例][ruby]{
bar], [1, 2.to_h # => {:foo => :bar, 1 => 2}
//}
ブロックを指定すると配列の各要素でブロックを呼び出し、
その結果をペアとして使います。
//emlist[ブロック付きの例][ruby]{
["foo", "bar"].to_h {|s| [s.ord, s]} # => {102=>"foo", 9... -
Array
# to _ csv(**options) -> String (6114.0) -
CSV.generate_line(self, options) と同様です。
...同様です。
Array オブジェクトを 1 行の CSV 文字列に変換するためのショートカットです。
@param options CSV.generate_line と同様のオプションを指定します。
//emlist[][ruby]{
require 'csv'
p [1, 'Matz', :Ruby, Date.new(1965, 4, 14)].to_csv......# => "1,Matz,Ruby,1965-04-14\n"
p [1, 'Matz', :Ruby, Date.new(1965, 4, 14)].to_csv(col_sep: ' ', row_sep: "\r\n") # => "1 Matz Ruby 1965-04-14\r\n"
//}
@see CSV.generate_line... -
Array
# to _ h -> Hash (6108.0) -
self を [key, value] のペアの配列として解析した結果を Hash にして 返します。
...self を [key, value] のペアの配列として解析した結果を Hash にして
返します。
//emlist[例][ruby]{
bar], [1, 2.to_h # => {:foo => :bar, 1 => 2}
//}... -
Array
# to _ s -> String (3108.0) -
自身の情報を人間に読みやすい文字列にして返します。
...自身の情報を人間に読みやすい文字列にして返します。
//emlist[例][ruby]{
[1, 2, 3, 4].to_s # => "[1, 2, 3, 4]"
[1, 2, 3, 4].inspect # => "[1, 2, 3, 4]"
//}... -
Array
# combination(n) -> Enumerator (143.0) -
サイズ n の組み合わせをすべて生成し、それを引数としてブロックを実行します。
...出されると、組み合わせ
を生成する Enumerator オブジェクトを返します。
@param n 生成される配列のサイズを整数で指定します。
整数以外のオブジェクトを指定した場合は to_int メソッドによる暗
黙の型変換を......ombination(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 (143.0) -
サイズ n の順列をすべて生成し,それを引数としてブロックを実行します。
...で呼び出されると, 順列
を生成する Enumerator オブジェクトを返します。
@param n 生成する配列のサイズを整数で指定します。
整数以外のオブジェクトを指定した場合は to_int メソッドによる暗
黙の型変換を試......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......した配列の各要素を引数としてブロックを実
行して 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 (137.0) -
サイズ n の重複組み合わせをすべて生成し、それを引数としてブロックを実行 します。
...出されると、
組み合わせを生成する Enumerator オブジェクトを返します。
@param n 生成される配列のサイズを整数で指定します。
整数以外のオブジェクトを指定した場合は to_int メソッドによる暗
黙の型変換を......tion(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 #=>......して 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...