Magic Methods Help | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Magic Methods Help

I need some help understanding magic methods. I understand most of it but im not seeing how a few things work like how can other have other.x and other.y...also how is it adding both bottom values https://code.sololearn.com/cGmPHDcEi9ZG/?ref=app https://code.sololearn.com/cGmPHDcEi9ZG/?ref=app

22nd Apr 2021, 3:08 AM
Redriver
Redriver - avatar
5 Answers
0
The __add__ method is called by the + operator, and is passed “second” as an argument. Thus, thr vector assigned to “second” appears as the parameter “other” in the __add__ code.
22nd Apr 2021, 5:03 AM
Wilbur Jaywright
Wilbur Jaywright - avatar
0
yeah im still super confused 😕
22nd Apr 2021, 5:23 AM
Redriver
Redriver - avatar
0
Well... Maybe you should back up. This is very simple unless one didn’t learn OOP, in which case it could be very difficult.
22nd Apr 2021, 5:25 AM
Wilbur Jaywright
Wilbur Jaywright - avatar
0
Ill try to explain with code...
22nd Apr 2021, 5:27 AM
Wilbur Jaywright
Wilbur Jaywright - avatar
0
Here. Take a look at this code, then see the result. https://code.sololearn.com/co7aOas1U9jl/?ref=app
22nd Apr 2021, 5:31 AM
Wilbur Jaywright
Wilbur Jaywright - avatar