作者热门文章
- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
"Example_Value"} example["Example_Key"] 解释器会返回"Example_Value"-6ren">
如果我输入如下内容:
example = {"Example_Key" => "Example_Value"}
example["Example_Key"]
解释器会返回"Example_Value"
,也就是值。有没有办法输入值并获取 key ?
最佳答案
是的,有:
example = {"Example_Key" => "Example_Value"}
example.key "Example_Value" # => "Example_Key"
查看文档 Hash#key
Returns the key of an occurrence of a given value. If the value is not found, returns
nil
.
关于ruby - 有没有办法从值中访问键?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24720597/
我是一名优秀的程序员,十分优秀!