LoginSignup
6
6

More than 5 years have passed since last update.

Enumerable モジュールのメソッドを類似グループ分け

Last updated at Posted at 2015-03-17

個人的なイメージです。

要素それぞれ: each/reverse_each/cycle/each_entry
要素それぞれと付随物を: each_with_index/each_with_object
要素を元とした配列: map(collect)/flat_map
合わせた配列: zip
畳み込み: inject(reduce)
条件を満たすか: all?/any?/one?/none?
要素に含まれているか: include?(member?)
要素を一つ探す: find(detect)/find_index
一定数毎に要素区分け: each_cons/each_slice
先頭から抜き出し/叩き落とした配列: first/drop/drop_while/take/take_while
条件を満たす要素を抜き出した配列: select(find_all)/reject/partition/grep
条件がキー、条件を満たす要素が配列の値にしたハッシュ: group_by
条件を満たす要素で区分け: chunk/slice_before/slice_after/slice_when
最大最小: max/min/minmax/max_by/min_by/minmax_by
並べ替え: sort/sort_by
変換: to_a(entries)/to_h
数え上げ: count
遅延評価: lazy

参考:module Enumerable

関連:

6
6
1

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
6
6