Is there a reverse method for `Array # include?`?

I always wondered if there is a converse method for include? . So, considering:

 str = "a" ary = ["a", "b", "c"] 

I can check if the string is in the array and not whether the array contains the string. Sort of:

 str.in?(ary) 

I can’t think of a situation where this is necessary, but often I think from this direction, and not vice versa.

+5
source share
1 answer

There is no such method in Ruby, but there is such a method in Rails - Object#in

+5
source

Source: https://habr.com/ru/post/1240752/


All Articles