Skip to content

Operator Overloading

Trin Wasinger edited this page Nov 14, 2024 · 1 revision

Binary Operators

An expression x op y is evaluated as follows:

  • if x is a primitive and y is an object with op, y[op](x, y)
  • if x is an object with op and y is a primitive, x[op](x, y)
  • if y has op and is a subclass of x, y[op](x,y)
  • if x has op and is a subclass of y, x[op](x,y)
  • if x has op, x[op](x,y)
  • if y has op, y[op](x,y)
  • else builtin(x,y)
Clone this wiki locally