本文介绍了为什么Ruby只允许某些运算符重载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Ruby中,就像许多其他OO编程语言一样,运算符是可重载的.但是,只有某些字符运算符可以重载.
In Ruby, like in many other OO programming languages, operators are overloadable. However, only certain character operators can be overloaded.
此列表可能不完整,但是,有些操作符不能重载:
This list may be incomplete but, here are some of the operators that cannot be overloaded:
!, not, &&, and, ||, or
推荐答案
方法是可重载的,它们是语言语法的一部分.
Methods are overloadable, those are part of the language syntax.
这篇关于为什么Ruby只允许某些运算符重载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!