Module: ArrayTweaks::Extension
- Defined in:
- lib/array-tweaks.rb
Instance Method Summary collapse
Instance Method Details
#drop_last ⇒ Object
6 7 8 |
# File 'lib/array-tweaks.rb', line 6 def drop_last slice(0, (size - 1).abs) # or slice(0...-1) end |
#drop_last! ⇒ Object
10 11 12 |
# File 'lib/array-tweaks.rb', line 10 def drop_last! slice!(-1) end |
#each_with_index_and_size ⇒ Object
14 15 16 17 |
# File 'lib/array-tweaks.rb', line 14 def each_with_index_and_size size = self.size each_with_index { |item, index| yield(item, index, size) } end |