Expected identifier but got "+=" purchase[msg.sender]

Hello everyone, I am just beginning with solidity , can someone tell me what mistake i have made here.


thank you gyz

1 Like

It seems like the defined of purchase is mapping(address => uint) purchase, so I think maybe the mapping can not use += with the type uint. So maybe it should be:

purchase[msg.sender] = purchase[msg.sender] + numberoftickets;

BTW, I think in the compile version of 0.7.x, you had better use the library SafeMath.sol to avoid overflow and underflow

2 Likes

Hi @sanjivy_raja,

Welcome to the community :wave:

1 Like

@abcoathup thank you

1 Like

@Skyge thank you so much, will try it

1 Like