Ruby/Hash/clear

Материал из Wiki.crossplatform.ru

Версия от 17:57, 13 сентября 2010; ViGOur (Обсуждение | вклад)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

clear a hash

counties = { "Three" => 3, "Five" => 5 }
counties.clear # bye-bye



clear method removes all the key-value pairs from a hash, leaving it empty

counties = { "Three" => 3, "Five" => 5 }
counties.clear # bye-bye
counties.empty? # => true