+= operator with if statement gives errors

2023-04-17 Thread Araq
Read grammar.txt to find out why: A binary expression consists of `primary` expressions and their definition is: primary = simplePrimary (commandStart expr) / operatorB primary / routineExpr / rawTypeDesc / prefixOperator primary

+= operator with if statement gives errors

2023-04-17 Thread planetis
>From my limited understanding, I would guess that the parser is having trouble >when encountering a if expression as argument to a infix operator. In this >case += but I have seen the error with & as well.

+= operator with if statement gives errors

2023-04-17 Thread freeflow
Thanks for the feedback, the suggestions give me a workaround. But I'm still interested in understanding the Why

+= operator with if statement gives errors

2023-04-17 Thread cblake
This also works (with or without parens): inc myFloor, if myMoves == UP: 1 else: -1 Run

+= operator with if statement gives errors

2023-04-17 Thread Jaap
myFloor += (if myMoves == UP: 1 else: -1) will work

+= operator with if statement gives errors

2023-04-17 Thread freeflow
I'd appreciate a pointer as to why I'm getting two errors for this line of code one for the + in += One for 'if myMoves == UP: 1 else: -1' myFloor += if myMoves == UP: 1 else: -1 Run myfloor is defined as int, myMoves is derived from 'for myMoves in s.data' where