Class: Array

Inherits:
Object
  • Object
show all
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

Instance Method Details

#count_elementsObject



4
5
6
# File 'lib/array/count_array.rb', line 4

def count_elements
  uniq.to_h { |el| [el, count(el)] }
end

#increase_with_indexObject



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_positionObject



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_soloObject



4
5
6
# File 'lib/array/select_array.rb', line 4

def select_solo
  select { |el| one?(el) }
end

#split_by_parityObject



4
5
6
# File 'lib/array/split_array.rb', line 4

def split_by_parity
  partition(&:even?)
end