I was just experimenting with creating a hash and then interating over it and I keep getting an error


#1



https://www.codecademy.com/en/courses/ruby-beginner-en-F3loB/3/3?curriculum_id=5059f8619189a5000201fbcb


It keeps saying that it was expecting an ''end" after China and I don't know why.
There is another hash and iteration of that hash on top of this one. Is that why?

This is my code:

world_leaders = {
    "Barack Obama" => "United States"
    "Xi Jin Ping" => "China"
    "Shinzo Abe" => "Japan"
    "Vladimir Putin" => "Russia"
}

world_leaders.each do |country, leader|
    puts "#{country}: #{leader}"
end


#2

@mikec,
The world_leaders object

  • has 4 properties
    • each consisting of a property-key and its associated Value
    • and the properties should be separated from eah other by a comma-,

world_leaders = {
    "Barack Obama" => "United States",
    "Xi Jin Ping" => "China",
    "Shinzo Abe" => "Japan",
    "Vladimir Putin" => "Russia"
}

#3

@leonhard.wettengmx.n

Oh, yeah. Thanks!


#4

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