In this section you provided refactored code for multiplication with lambda function:
from functools import reduce
class SimpleCalculator:
[...]
def mul(self, *args):
return reduce(lambda x, y: x*y, args)
My note is not related to the testing itself, but maybe it will be useful - we can also use mul function from the standard operator package to have the following code:
from functools import reduce
from operator import mul
class SimpleCalculator:
[...]
def mul(self, *args):
return reduce(mul, args)
Hi Leonardo,
In this section you provided refactored code for multiplication with lambda function:
My note is not related to the testing itself, but maybe it will be useful - we can also use
mul
function from the standardoperator
package to have the following code:Thank you.