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.
我有一个哈希表,其中有多个值被传递给一个函数我不知道键的名称,但我知道键的值必须等于字符 AS 或 X。如何轻松检查哈希中的所有值表是否等于那些字符?
NullUserException 很好,你也可以
match_values = %w(A S X) hash.values.all? { |value| match_values.include?(value) }