Magic Methods Help | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
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 Respostas
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