14. Multidimensional Arrays. Code looks ok and works, but course wont let me go further


The code looks ok and it works, but the course page shows this message and I can't finish exercise. Whats wrong?
Error message: Oops, try again. It looks like my_array isn't an array.

my_array = {
    "joey" => "tribiani",
    "rachel" => "green",
    "monica" => "geller"

my_array.each do |name, surname| 
    puts "#{name}: #{surname}"


an array is inside of bracket notation...
did you read the hint?
This is an example of what it should look like:

array = [[thing, thing], [thing, thing]]


I tried to write it this way - didn't work at all. And, as I understand, it's possible to write it two ways. This is the example from the course:
secret_identities = {
"The Batman" => "Bruce Wayne",
"Superman" => "Clark Kent",
"Wonder Woman" => "Diana Prince",
"Freakazoid" => "Dexter Douglas"
secret_identities.each do |character, person|
puts "#{character}: #{person}"

"bracket notation" way:
my_array = [[joey, tribiani], [rachel, green], [monica, geller]]

my_array.each do |name, surname|
puts "#{name}: #{surname}"

compilator message: undefined local variable or method `joey' for #
And "Oops, try again. It looks like my_array isn't an array"


Those create different data structures:

puts [].class  # Array
puts {}.class  # Hash

Have a look at ruby's error message, it mentions using an undefined name


Oh, I got it. Stupid mistake:) Thanks:)


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