为什么我的哈希值会出现语法错误?

时间:2015-09-18 00:50:06

标签: ruby

下面是哈希:

 hash = { 
     :home => {:team_name => "Brooklyn Nets", :colors => ['black','white'], 
       :players => { 
       { player_name: "Alan Anderson", 
         number: '0', 
         shoe: '16', 
         points: 22, 
         rebounds: 12, 
         assists: 12 , 
         steals:3 , 
         blocks:1,
         slam_dunks:1 }
      }
    },
   :away => [:team_name, :colors, :players]
  }

有谁可以告诉我为什么我一直收到这个错误?

syntax error, unexpected '\n', expecting =>

它说这发生在slam_dunks行。

1 个答案:

答案 0 :(得分:1)

    hash = {
    home => {:team_name => "Brooklyn Nets", :colors => ['black','white'],
              :players => {
                  player_name: "Alan Anderson",
                    number: '0',
                    shoe: '16',
                    points: 22,
                    rebounds: 12,
                    assists: 12 ,
                    steals:3 ,
                    blocks:1,
                    slam_dunks:1 
              }
    },
    :away => [:team_name, :colors, :players]
}

删除播放器键内的额外括号,这导致错误。