ruby - Understanding coercion -
I submitted one, which modifies the matrix class so that the joints are real The number can be:
matrix [[25, 93], [-1, 66]] + 5
matrix The class is a way of + () , which is said in this case.
I would also like you to be able to change the order of operation
5 + matrix [[25, 93], [-1, 66]] < / Code>
Matrix seems to support this command of operation * () method and I call it + () method is unsure of how to implement
force course Method is controlled. This method is to return two elements, for which the operator / method has to retry. matrix defines shutdown as:
def corse (other) case when other numerical return Scalar.new (other), self Increase TypeError, "# {Self.class}" can not be terminated at the end Note that this order of operands is not changing , But converts them to a scaler in the numeric value in the class. Therefore, Ruby will see 5 + matrix [...] Scalar.new (5) + matrix [...] .
The + and ' Are included. So what you need to do is get rid of line Scalar.Raise ErrOperationNotDefined, "@", @ value.class, other.class and apply your code here, for example other + With Self
Comments
Post a Comment