Class: Array
- Inherits:
-
Object
- Object
- Array
- Defined in:
- lib/array/count_array.rb,
lib/array/split_array.rb,
lib/array/select_array.rb,
lib/array/increase_array.rb
Instance Method Summary collapse
- #count_elements ⇒ Object
- #increase_with_index ⇒ Object
- #increase_with_position ⇒ Object
- #select_solo ⇒ Object
- #split_by_parity ⇒ Object
Instance Method Details
#count_elements ⇒ Object
4 5 6 |
# File 'lib/array/count_array.rb', line 4 def count_elements uniq.to_h { |el| [el, count(el)] } end |
#increase_with_index ⇒ Object
4 5 6 |
# File 'lib/array/increase_array.rb', line 4 def increase_with_index map&.with_index { |el, i| el + i } end |
#increase_with_position ⇒ Object
8 9 10 |
# File 'lib/array/increase_array.rb', line 8 def increase_with_position map&.with_index(1) { |el, i| el + i } end |
#select_solo ⇒ Object
4 5 6 |
# File 'lib/array/select_array.rb', line 4 def select_solo select { |el| one?(el) } end |
#split_by_parity ⇒ Object
4 5 6 |
# File 'lib/array/split_array.rb', line 4 def split_by_parity partition(&:even?) end |