each_key method passes only the keys to the block : each_key « Hash « Ruby






each_key method passes only the keys to the block


zip = { 1 => "One", 2 => "Two", 3 => "Three",
4 => "Four", 5 => "Five", 6 => "Six", 7 =>
"Seven", 8 => "Eight", 9 => "Eight" }

zip.each_key { |key| print key, " " }

 








Related examples in the same category

1.Loop through all keys