- Notifications
You must be signed in to change notification settings - Fork1.4k
Implement __sub__/__rsub__.#188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
| @@ -0,0 +1,21 @@ | |||
| assert5-3==2 | |||
| classComplex(): | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Notecomplex builtin type is also present, no issue here though.
| def__repr__(self): | ||
| return"Com"+str((self.real,self.imag)) | ||
| def__sub__(self,other): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Good check! Here lies the proof of the pudding indeed!
vm/src/vm.rs Outdated
| } else if b.has_attr("__rsub__") { | ||
| self.call_method(&b, "__rsub__", vec![a]) | ||
| ifletOk(method) =self.get_method(a.clone(),"__sub__"){ | ||
| self.invoke( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Maybe we can add ainvoke_with_args method which is less vebose.
Example of how to call attrs that exist.