Syntax error on my operator?


#1

#2

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


#3

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

I tried that. It doesn’ work.


#4

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


#5

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