hal*_*bit 6 ruby ruby-on-rails
我尝试只使用:我的应用程序中关键词的符号.我尝试严格决定:symbol => logic或string => UI/language specific
但是我每个JSON也得到一些"值"(即选项等等),因为JSON中没有:符号,所有调用的哈希都具有"with_indifferent_access"属性.
但是:数组有相同的东西吗?像那样
a=['std','elliptic', :cubic].with_indifferent_access
a.include? :std => true
Run Code Online (Sandbox Code Playgroud)
?
编辑:为标签添加了rails
a = ['std','elliptic', :cubic].map(&:to_sym)
a.include? :std
#=> true
Run Code Online (Sandbox Code Playgroud)
编辑 - 关于 maxigs 的评论可能更好地转换为字符串:
a = ['std', 'elliptic', :cubic].map(&:to_s)
a.include? "std"
#=> true
Run Code Online (Sandbox Code Playgroud)