可以覆盖/实现的ruby运算符列表

aaa*_*dan 24 ruby operator-overloading operators

是否有可以覆盖的所有ruby运算符的列表?(不是那些不能!)

Mar*_*off 33

这是Ruby运算符的表.

方法和可重载的是:

[ ] [ ]=    Element reference, element set
**  Exponentiation
! ~ + -     Not, complement, unary plus and minus (method names for the last two are +@ and -@)
* / %   Multiply, divide, and modulo
+ -     Plus and minus
>> <<   Right and left shift
&   Bitwise `and'
^ |     Bitwise exclusive `or' and regular `or'
<= < > >=   Comparison operators
<=> == === != =~ !~     Equality and pattern match operators (!= and !~ may not be defined as methods)
Run Code Online (Sandbox Code Playgroud)

该表来自2001年的Pickaxe书,但这与Ruby 1.9 Pickaxe书中的表相同 - 没有理由相信这组中缀运算符将会改变.