我正在为电影名称存储创建一个Ruby哈希.
当哈希的键是包含空格的字符串时,它可以正常工作.
如:
movies = {"Avatar" => 5, "Lord of the rings" => 4, "Godfather" => 4}
现在我试图用符号替换字符串的使用:
movies = {Avatar: 5, Lord of the rings: 4, Godfather: 4}
显然这不起作用.
Ruby如何处理符号命名中的空格?
ruby hash symbols
hash ×1
ruby ×1
symbols ×1