ruby - string.include 的奇怪行为?在 ruby

标签 ruby string

我不明白为什么 include? 在这两种情况下都返回 true。谁能赐教一下?

"".include?("") # => true
"stackoverflow".include?("") # => true

documentation状态:

include? other_str → true or false
Returns true if str contains the given string or character.

最佳答案

因为字符串“stackoverflow”在字母/字符之间包含无限数量的空字符串。

关于ruby - string.include 的奇怪行为?在 ruby ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19583213/

相关文章:

ruby-on-rails - 如何检查 Ruby View 中的对象是否为 nil?

ruby - "at"印记 (@) 在 Ruby 函数中给出什么范围?

c++ - 在数组中搜索字符串

c - 尝试将唯一的单词读入文件,但内存分配出现问题

ruby-on-rails - 使用 Ruby (on Rails) 确认链接创建

ruby - :method: notation supposed to do for ruby docs?到底是什么

ruby-on-rails - rails : rendering json with multiple objects

C++从字符串创建二元组

java - 比较字符串和整数 (java)

无法设置 C char 数组元素