检查Ruby中的数组中是否存在值 - Check if a value exists in an array in Ruby

问题:

I have a value 'Dog' and an array ['Cat', 'Dog', 'Bird'] . 我有一个值'Dog'和一个阵列['Cat', 'Dog', 'Bird'] 数组

How do I check if it exists in the array without looping through it? 如何在没有循环的状况下检查数组中是否存在? Is there a simple way of checking if the value exists, nothing more? 是否有一种简单的方法来检查值是否存在,仅此而已? oop


解决方案:

参考一: https://stackoom.com/question/8KkU/检查Ruby中的数组中是否存在值
参考二: https://oldbug.net/q/8KkU/Check-if-a-value-exists-in-an-array-in-Ruby
相关文章
相关标签/搜索