如果我有哈希
{"one"=>1, "two"=>2, "three"=>3}
Run Code Online (Sandbox Code Playgroud)
映射键以获取数组的最佳方法是什么:
["one", "two", "three"]
Run Code Online (Sandbox Code Playgroud)
{"one"=>1, "two"=>2, "three"=>3}.keys #=> ["one", "two", "three"]
Run Code Online (Sandbox Code Playgroud)
该文档非常适合发现这些问题的答案.
如果问题是"我如何从Y型对象获取X数据?",那么通过对象类型Y的文档阅读应该是你要去的第一个地方.