Iterating over Hashes


With the following array:

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

The only answer that is accepted is:
secret_identities.each {|n,tn| "#{n}: #{tn}"}

My answer was this; I may be a head of the class structure, but the values are the same; this should be accepted.
secret_identities.each {|n,tn| puts n+" : "+tn}


Both methods work,


But in the lesson you can only pass if you follow the instructions and write your code based on them in order to pass the SCT. :slight_smile:


I must have missed the description of what this "#{var} structure does?
Just tried to do a google search on it and could not find anything. Can you
to a brief review?



Is a Ruby placeholder that stores values, but it must have an input from where it is receiving the info it will then display#{}


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