【发布时间】:2013-02-27 12:13:17
【问题描述】:
我正在为电影名称存储创建一个 Ruby 哈希。
当哈希的键是包含空格的字符串时,它工作得很好。
如:
movies = {"Avatar" => 5, "Lord of the rings" => 4, "Godfather" => 4}
现在我正在尝试用符号代替字符串的使用:
movies = {Avatar: 5, Lord of the rings: 4, Godfather: 4}
显然这行不通。
Ruby 如何处理符号命名中的空格?
【问题讨论】: