Are there null like thing in solidity

0 votes
struct buyer{
       uint amount;
       Status status;
    }

    mapping(address=>buyer) public buyers;
    mapping(uint=>address) buyerIndex;
    uint public buyerNum;
    //Order a product.
    function(){
      uint doubleValue=value*2;
      uint amount=msg.value/doubleValue; 
      if(buyers[msg.sender]==null){ //Error in this line
      buyer abuyer=buyer({amount:amount,status:Status.Created}); //Error in this line
      buyerNum++;
      buyerIndex[buyerNum]=msg.sender;
      buyers[msg.sender]=abuyer;
    }else{
      buyers[msg.sender].amount+=amount;
    }
      Order(msg.sender,amount*doubleValue,amount);

 }

If a buyer is not recorded int the buyer mapping, then buyerNum++; but I don'k how to tell whether a buyer is in the mapping

Sep 21, 2018 in Blockchain by slayer
• 29,050 points
26 views

1 answer to this question.

0 votes

You could create none variable to use it as a NULL:

uint80 constant None = uint80(0); 
answered Sep 21, 2018 by digger
• 27,630 points

Related Questions In Blockchain

+1 vote
1 answer
+1 vote
1 answer

What is the difference between if() and require() statement in solidity??

If() and require() have separate functions and ...READ MORE

answered Apr 18, 2018 in Blockchain by Shashank
• 10,330 points
336 views
+1 vote
1 answer

what is use of msg.sender in solidity code?

msg.sender(address) function indicated the sender of the ...READ MORE

answered Apr 24, 2018 in Blockchain by Shashank
• 10,330 points
346 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
123 views
+1 vote
3 answers

Removing double quotes from a string from JSON response in PHP

Just remove the json_encode call, and it should work: $resp ...READ MORE

answered Sep 12, 2018 in Blockchain by digger
• 27,630 points
2,480 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Why is there no infinite loop problem in Hyperledger Fabric?

Hyperledger uses a timeout mechanism for chaincode ...READ MORE

answered Jul 29, 2018 in Blockchain by digger
• 27,630 points
88 views