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.
我有一个字符串数组:
string_array = ['memberid', 'membershiptype', 'date']
现在我需要检查这个数组是否包含'id',并且我希望它返回 true。
'id'
我知道我可以做到string_array.include? 'memberid',但我需要在'id'.
string_array.include? 'memberid'
string_array.any? { |e| e.include? 'id' }
any?如果数组中的任何元素对于给定的谓词(即传递给的块any?)为真,则返回真
any?