LoginSignup
4
4

More than 5 years have passed since last update.

Array クラスのメソッドを類似グループ分け

Last updated at Posted at 2015-03-18

個人的なイメージです。

要素取得: slice([])/slice!/at([])/fetch/first/last/values_at/sampleslice!の返値注意)
要素の位置を取得: index(find_index)/rindex
配列先頭での処理: shift/unshift
配列末尾での処理: pop/push/concat/<</+
要素挿入: insert/[]=
要素置き換え: fill/replace
条件に従い要素を削除: delete_if/keep_if
条件に従い要素を削除(返値注意): reject!/select!
要素削除: clear/-
要素削除: delete/delete_atdeleteの返値注意)
nil除去: compact/compact!compact!の返値注意)
重複削除: uniq/uniq!uniq!の返値注意)
要素順入れ替え: reverse/reverse!/rotate/rotate!/shuffle/shuffle!/sort/sort!/sort_by/sort_by!
要素を元に配列を作り置き換える: map!(collect!)
組み合わせて配列を作る: zip
平滑化: flatten/flatten!flatten!の返値注意)
変換: join/to_s(inspect)/pack/to_a/to_ary/to_h/*
要素それぞれ: each/each_index/reverse_each
浅い複製: dup/clone
数量: size(length)/empty?
比較: <=>/==/eql?
順列・組み合わせ: permutation/repeated_permutation/combination/repeated_combination
行列演算: transpose
集合演算: &/|/product
Hash的配列(配列の配列)の要素を一つ返す: assoc/rassoc
ソート済み配列を二分探索: bsearch

これらに加えて Enumerable モジュールのメソッド も。

参考:class Array

関連:

4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4