Mega Code Archive

 
Categories / Ruby / Array
 

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"