ruby-on-rails - 有没有相反的“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])
?
解决方案
不,没有这样的方法。如果有,将在此处定义:https ://github.com/rails/rails/blob/v6.0.2.1/activesupport/lib/active_support/core_ext/object/inclusion.rb )。
推荐阅读
- selenium - 有没有一种简单的方法可以捕获 chrome 中包含 iframe 之外的元素的完整路径?
- java - 我正在使用 eclipse 并创建 BDD 框架。在我的跑步者文件中,Import cucumber.api is notsolved 如何解决这个问题?
- netsuite - NetSuite Rest Web 服务查询上次更新
- tensorflow - 在 TPU 上使用全局批量大小进行训练(张量流)
- javascript - 正在调度操作,但状态未更新
- react-native - 如何清除所有抽屉堆栈并注销应用程序表单 React native
- php - 将 Woocommerce 计费状态字段覆盖为普通输入字段,而不会丢失帖子数据并且需要重写整个帖子机制
- html - 如何更改 div 内容高度内的 span 高度?
- azure - 在创建 microsoft.botservice 已在资源提供程序中注册的机器人通道时面临问题
- search - 如何在 FaunaDB 中进行文本搜索