Iterating Over Hashes


I've gone over this a million times and have compared it to other's work, but it still doesn't work, what am I doing wrong?

secret_identities = {
  "The Batman" => "Bruce Wayne",
  "Superman" => "Clark Kent",
  "Wonder Woman" => "Diana Prince",
  "Freakazoid" => "Dexter Douglas"

secret_idententies.each do |super, not|
    puts "#{super}: #{not}"

(ruby):7: syntax error, unexpected keyword_super, expecting '|'
secret_idententies.each do |super, not|


Check the spelling of your variables.
secret_identities != secret_idententies.each


Apart from the mentioned spelling error, the code is using two reserved words for variable names. We should never use keywords as variable names.

secret_identities.each do |key, value|
    puts "#{key}: #{value}"


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.