delete method removes a matching object from an array, returning the deleted object if found. : delete « Array « Ruby






delete method removes a matching object from an array, returning the deleted object if found.



month_a = %w[ nil jan feb mar apr may jun jul aug sep oct nov dec ] # => ["nil","jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"]

# The following call deletes the string nil from month_a:

month_a.delete "nil"

 








Related examples in the same category

1.Array.delete takes a block.