【问题标题】:What is the ruby Regex or String #=== method/operator? [duplicate]什么是红宝石正则表达式或字符串#=== 方法/运算符? [复制]
【发布时间】:2012-04-19 04:20:07
【问题描述】:

可能重复:
=== vs. == in Ruby

我根本找不到详细的文档。文档页面已损坏:

http://ruby-doc.org/core-1.9.3/String.html

正则表达式页面在两种不同的意义上使用“大小写”一词(!),我不明白重点是什么:

http://www.ruby-doc.org/core-1.9.3/Regexp.html#method-i-3D-3D-3D

它在 Rails 中使用:

https://github.com/rails/rails/commit/3756a3fdfe8d339a53bf347487342f93fd9e1edb?utm_source=rubyweekly&utm_medium=email

【问题讨论】:

    标签: ruby regex operators


    【解决方案1】:

    === 是“大小写相等”运算符:

    在 Ruby 中,三等号 (Object#===) 是“实际上与调用 #== 相同,但通常会被后代覆盖以在 case 语句中提供有意义的语义”。

    http://andy-payne.com/2008/09/confusion-over-triple-equals/

    【讨论】:

      猜你喜欢
      • 2012-11-06
      • 1970-01-01
      • 1970-01-01
      • 2016-01-20
      • 2021-11-22
      • 2011-08-12
      • 1970-01-01
      • 1970-01-01
      • 2016-12-14
      相关资源
      最近更新 更多