首页 > 解决方案 > 有没有相反的“in”方法?在 Rails 中?

问题描述

in?Rails 中是否有相反的方法?

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

目前,我正在使用[1,2,3].exclude?(3)or !3.in?([1,2,3])

有没有类似的方法3.out_of([1,2,3])

标签: ruby-on-railsruby

解决方案


不,没有这样的方法。如果有,将在此处定义:https ://github.com/rails/rails/blob/v6.0.2.1/activesupport/lib/active_support/core_ext/object/inclusion.rb )。


推荐阅读