首页 > 解决方案 > 我不断收到与我的哈希有关的错误

问题描述

我在Repl.it上做了一个哈希,我已经尝试了所有方法,但我一直收到同样的错误。

我对哈希进行了更多研究,并且学到了很多东西。我十四岁,我已经在 ruby​​ 2.5.5 上遇到了一个重大问题。

这是我做的哈希

name_hash {15 => "Michael", 13 =>"Christopher",114 =>"Ryan" 

预期的结果是没有错误,但我只是带着这个错误回来

(repl):9: syntax error, unexpected =>, expecting '}'
name_hash {15 => "Michael", 13 =>"Christopher...
              ^~
(repl):9: syntax error, unexpected ',', expecting end-of-input
name_hash {15 => "Michael", 13 =>"Christopher",114 =>"Ry...

标签: ruby

解决方案


尝试这个:

name_hash = {15 => "Michael", 13 =>"Christopher",114 =>"Ryan"}

推荐阅读