Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想检查一个关键的“测试”是否包含在带有 Rails 的哈希中。我尝试了has_key?('test') 方法,但出现以下错误。
has_key?
未定义的方法“has_key?”
如何检查密钥是否包含? 提前致谢。
h = {a:1, b:2, c:3} h.has_key? :a =>true
这应该在rails中工作。您的代码肯定有另一个问题。请分享。