Meta methods
Meta methods are methods that can be defined on classes to overload operators or other specific behavior.
Below is a list of each meta method name along with it's corresponding operator (or functionality). Each operator listed is binary unless otherwise stated.
Operator overloading
add$
-+
sub$
--
mul$
-*
div$
-/
idiv$
-//
- same as(a / b).floor
pow$
-^
- exponentation, not XORmod$
-%
gte$
->=
lte$
-<=
unm$
--
(unary)unp$
-+
(unary)size$
-#
bnot$
-~
(unary)band$
-&
bor$
-|
bshr$
->>
bxor$
-~
bshl$
-<<
Other
to_string
- calls when casting to string (e.x.<string>abc
will callabc->to_string
if it's a class instance)is_in$
- calls when using anis in
expression (e.x.foo is in bar
will callbar->is_in$(foo)
)
Last updated