What is the main reason for using magic methods? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is the main reason for using magic methods?

I understand how the code compiles step by step but I am not getting why we need to use magic methods and operator overloading. Can anyone please help me with clear explanation of this?

25th Oct 2016, 7:40 PM
Misty Moon
Misty Moon - avatar
1 Answer
+ 4
They allow for synthax simplifications. They can turn obj1.add(obj2) into obj1 + obj2 for example.
25th Oct 2016, 10:48 PM
Zen
Zen - avatar