If array = [1, 2, 3, 4, 5, 6, 7, 8, 9],
I want to delete a range of elements from array.
For example: I want to delete all elements with an index in th
One of the many ways to do this is to invoke Array#delete_if with a block that checks whether each element of the Array is included in the Range with Array#include?. For example:
array = [1, 2, 3, 4, 5, 6, 7, 8, 9]
array.delete_if { |i| (2..5).include? i }
#=> [1, 6, 7, 8, 9]