Ruby:重写常量(范围)解析操作符?(::)

Ruby:重写常量(范围)解析操作符?(::),ruby,Ruby,根据这一点,可以重写Ruby中的常量分辨率操作符。(向下滚动到页面底部)是真的吗?如果是这样的话,我该怎么做?我为什么要这样做?Ruby编程语言只列出这些可定义的运算符: ! ~ + # Boolean NOT, bitwise complement, unary plus ** # Exponentiation - # Unary minus (define with-@) *

根据这一点,可以重写Ruby中的常量分辨率操作符。(向下滚动到页面底部)是真的吗?如果是这样的话,我该怎么做?我为什么要这样做?

Ruby编程语言只列出这些可定义的运算符:

! ~ +                  # Boolean NOT, bitwise complement, unary plus
**                     # Exponentiation
-                      # Unary minus (define with-@)
* / %                  # Multiplication, division, modulo (remainder)
+ -                    # Addition (or concatenation), subtraction
<< >>                  # Bitwise shift-left (or append), bitwise shift-right
&                      # Bitwise AND
| ^                    # Bitwise OR, bitwise XOR
< <= >= >              # Ordering
== === != =~ !~ <=>    # Equality, pattern matching, comparison
!~+#布尔NOT、按位补码、一元加号
**#指数化
-#一元负号(用-@定义)
*/%#乘、除、模(余数)
+-#加法(或串联)、减法
>#按位左移(或追加),按位右移
&#按位和
|^#按位或,按位异或
<=>#订购
== === != =~ !~     # 相等、模式匹配、比较
资料来源:松本幸弘:“Ruby编程语言”第102页(2008年,第一版)


所以我猜你引用的网页完全是错的。

“我为什么要这么做?”-让大家都恨你。:)好吧,是的,我想可能是这样的,因为我不知道如何在IRB中工作。