Ruby/Array/delete
Материал из Wiki.crossplatform.ru
(Различия между версиями)
ViGOur (Обсуждение | вклад) м (1 версия: Импорт выборки материалов по Ruby) |
Текущая версия на 18:01, 13 сентября 2010
Array.delete takes a block.
month_a = %w[ nil jan feb mar apr may jun jul aug sep oct nov dec ] month_a.delete("noon") {"noon wasn"t found."}
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"