Skip to content

complex-numbers: operator overloading#1098

Merged
cmccandless merged 5 commits intoexercism:masterfrom
susg:issue-724
Jan 9, 2018
Merged

complex-numbers: operator overloading#1098
cmccandless merged 5 commits intoexercism:masterfrom
susg:issue-724

Conversation

@susg
Copy link
Contributor

@susg susg commented Nov 9, 2017

Replace add, sub, mul, div, with __add__, __sub__, __mul__,
__truediv__ to showcase use of Pythons's magic methods on
operator overloading.
Add __eq__ in example.py to compare two
ComplexNumber objects.

Closes #724
Closes #983 (duplicate PR by same author)

Replace add, sub, mul, div, with __add__, __sub__, __mul__,
__truediv__ to showcase use of Pythons's magic methods on
operator overloading.
Add __eq__ in example.py to compare two
ComplexNumber objects.

Closes exercism#724
Copy link
Contributor

@cmccandless cmccandless left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be helpful for users not familiar with magic methods to provide a hint in a hints.md file (see the implementation for simple-linked-list for an example. Note that the contents of hints.md must also appear in the exercise README.md.

def __truediv__(self, other):
pass

def abs(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can also be overloaded as __abs__.

@stale
Copy link

stale bot commented Dec 8, 2017

This issue has been automatically marked as abandoned because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the abandoned label Dec 8, 2017
@stale stale bot removed the abandoned label Dec 8, 2017
@cmccandless
Copy link
Contributor

@N-Parsons As this PR abandoned, but nearly finished, I went ahead and made the requested change. If there is nothing else, go ahead and merge.

@stale
Copy link

stale bot commented Dec 29, 2017

This issue has been automatically marked as abandoned because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@cmccandless cmccandless requested a review from N-Parsons January 2, 2018 05:41
@cmccandless cmccandless merged commit 48fc699 into exercism:master Jan 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants