1574件ヒット
[1-100件を表示]
(0.162秒)
キーワード
- & (12)
- * (24)
- + (12)
- - (12)
- <=> (12)
- == (12)
- [] (24)
- []= (24)
- abbrev (12)
- all? (21)
- any? (19)
- at (12)
- bsearch (24)
-
bsearch
_ index (20) - collect (24)
- collect! (24)
- combination (24)
- concat (21)
- count (36)
- cycle (12)
- delete (24)
-
delete
_ at (12) -
delete
_ if (24) - difference (7)
- dig (10)
-
drop
_ while (24) - each (24)
-
each
_ index (12) - eql? (12)
- fetch (36)
- fill (24)
- filter (14)
- filter! (14)
-
find
_ index (36) - first (24)
- flatten (12)
- flatten! (12)
- index (36)
- insert (12)
- intersection (6)
- join (12)
-
keep
_ if (24) - last (24)
- map (24)
- map! (24)
- max (18)
- min (18)
- minmax (12)
- none? (7)
- one? (21)
- pack (21)
- permutation (24)
- pop (12)
- product (24)
- reject (24)
- reject! (24)
-
repeated
_ combination (24) -
repeated
_ permutation (24) - replace (12)
-
reverse
_ each (24) - rindex (36)
- rotate (12)
- rotate! (12)
- sample (24)
- select (24)
- select! (24)
- shift (24)
- slice (12)
- slice! (24)
- sort (24)
- sort! (24)
-
sort
_ by! (24) - sum (18)
- take (12)
-
take
_ while (24) -
to
_ a (12) -
to
_ ary (12) -
to
_ csv (12) - union (7)
- unshift (12)
-
values
_ at (12) - zip (24)
- | (12)
検索結果
先頭5件
-
Array
# shift -> object | nil (6232.0) -
配列の先頭の要素を取り除いてそれを返します。 引数を指定した場合はその個数だけ取り除き、それを配列で返します。
...法として使えます。
@param n 自身から取り除きたい要素の個数を非負整数で指定します。
整数以外のオブジェクトを指定した場合は to_int メソッドによる暗
黙の型変換を試みます。
@raise TypeError 引数に整数以外......
@raise ArgumentError 引数に負の数を指定した場合に発生します。
//emlist[例][ruby]{
a = [0, 1, 2, 3, 4]
p a.shift #=> 0
p a #=> [1, 2, 3, 4]
p [].shift #=> nil
p [].shift(1) #=> []
//}
@see Array#push, Array#pop, Array#unshift... -
Array
# filter {|item| . . . } -> [object] (6220.0) -
各要素に対してブロックを評価した値が真であった要素を全て含む配列を 返します。真になる要素がひとつもなかった場合は空の配列を返します。
...の配列を返します。
ブロックを省略した場合は Enumerator を返します。
//emlist[例][ruby]{
[1,2,3,4,5].select # => #<Enumerator: [1, 2, 3, 4, 5]:select>
[1,2,3,4,5].select { |num| num.even? } # => [2, 4]
//}
@see Enumerable#select
@see Array#select!... -
Array
# first -> object | nil (6219.0) -
配列の先頭の要素を返します。要素がなければ nil を返します。
...配列の先頭の要素を返します。要素がなければ nil を返します。
//emlist[例][ruby]{
p [0, 1, 2].first #=> 0
p [].first #=> nil
//}
@see Array#last... -
Array
# last -> object | nil (6219.0) -
配列の末尾の要素を返します。配列が空のときは nil を返します。
...配列の末尾の要素を返します。配列が空のときは nil を返します。
//emlist[例][ruby]{
p [0, 1, 2].last #=> 2
p [].last #=> nil
//}
@see Array#first... -
Array
# filter! {|item| block } -> self | nil (6214.0) -
ブロックが真を返した要素を残し、偽を返した要素を自身から削除します。 変更があった場合は self を、 変更がなかった場合には nil を返します。
...//emlist[例][ruby]{
a = %w{ a b c d e f }
a.select! {|v| v =~ /[a-z]/ } # => nil
a # => ["a", "b", "c", "d", "e", "f"]
//}
ブロックが与えられなかった場合は、自身と select! から生成した
Enumerator オブジェクトを返します。
@see Array#keep_if, Array#reject!... -
Array
# to _ csv(**options) -> String (6156.0) -
CSV.generate_line(self, options) と同様です。
...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......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"
//}
Ruby 3.0 (CSV 3.1.9) から、次のオプションが使えるようになりました。
//emlist[][ruby......]{
require 'csv'
puts [1, nil].to_csv # => 1,
puts [1, nil].to_csv(write_nil_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
# first(n) -> Array (6134.0) -
先頭の n 要素を配列で返します。n は 0 以上でなければなりません。
...以上でなければなりません。
@param n 取得したい要素の個数を整数で指定します。
整数以外のオブジェクトを指定した場合は to_int メソッドによる暗
黙の型変換を試みます。
@raise TypeError 引数に整数以外の(暗......指定した場合に発生します。
@raise ArgumentError n が負値の場合発生します。
//emlist[例][ruby]{
ary = [0, 1, 2]
p ary.first(0)
p ary.first(1)
p ary.first(2)
p ary.first(3)
p ary.first(4)
# => []
# [0]
# [0, 1]
# [0, 1, 2]
# [0, 1, 2]
//}
@see Array#last... -
Array
# last(n) -> Array (6134.0) -
末尾の n 要素を配列で返します。n は 0 以上でなければなりません。
...以上でなければなりません。
@param n 取得したい要素の個数を整数で指定します。
整数以外のオブジェクトを指定した場合は to_int メソッドによる暗
黙の型変換を試みます。
@raise TypeError 引数に整数以外の(暗......指定した場合に発生します。
@raise ArgumentError n が負値の場合発生します。
//emlist[例][ruby]{
ary = [0, 1, 2]
p ary.last(0)
p ary.last(1)
p ary.last(2)
p ary.last(3)
p ary.last(4)
# => []
# [2]
# [1, 2]
# [0, 1, 2]
# [0, 1, 2]
//}
@see Array#first... -
Array
# combination(n) -> Enumerator (6132.0) -
サイズ n の組み合わせをすべて生成し、それを引数としてブロックを実行します。
...成する Enumerator オブジェクトを返します。
@param n 生成される配列のサイズを整数で指定します。
整数以外のオブジェクトを指定した場合は to_int メソッドによる暗
黙の型変換を試みます。
@raise TypeError 引数......st[例][ruby]{
a = [1, 2, 3, 4]
a.combination(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 #=> [] : no combinations of length 5
//}
ブロックが与えられた場合、作成した配列の各要素を引数としてブロックを実
行して self を返します。
//emlist[例][ruby]{
a = [1, 2, 3, 4]
result = []
a.combination(2) {|e| result << e} # =>... -
Array
# combination(n) {|c| block } -> self (6132.0) -
サイズ n の組み合わせをすべて生成し、それを引数としてブロックを実行します。
...成する Enumerator オブジェクトを返します。
@param n 生成される配列のサイズを整数で指定します。
整数以外のオブジェクトを指定した場合は to_int メソッドによる暗
黙の型変換を試みます。
@raise TypeError 引数......st[例][ruby]{
a = [1, 2, 3, 4]
a.combination(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 #=> [] : no combinations of length 5
//}
ブロックが与えられた場合、作成した配列の各要素を引数としてブロックを実
行して self を返します。
//emlist[例][ruby]{
a = [1, 2, 3, 4]
result = []
a.combination(2) {|e| result << e} # =>...