Hash#delete returns the value,  so you can combine one loop.