Syntax error on my operator?



return cost -= 50 is not possible, -= is a shorthand, without shorthand we get:

return cost = cost - 50

so you try to(re-)assign a variable and returning, that is too much operations in a single line


Does it mean I shall change “return cost -=50” to “cost = cost -50”?

I tried that. It doesn’ work.


that is a possibility. Then you will need to return cost later.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.