ruby-on-railsruby

Is there an opposite method of "in?" in Rails?


Is there an opposite method in? in Rails?

3.in?([1,2,3])
#=> true

Currently, I'm using [1,2,3].exclude?(3) or !3.in?([1,2,3]).

Is there a method like 3.out_of([1,2,3])?


Solution

  • No, there is no such method. If there were, it would be defined here: https://github.com/rails/rails/blob/v6.0.2.1/activesupport/lib/active_support/core_ext/object/inclusion.rb).