Horje
check if value in mapping is empty struct in solidity ethereum Code Example
check if value in mapping is empty struct in solidity ethereum
pragma solidity >=0.4.21 <0.6.0;

contract Test {

    struct Ticket {
       uint seatNumber;
    }

    mapping (string => Ticket) myMapping;

    function isExists(string memory key) public view returns (bool) {
        // check if non-zero value in struct is zero
        // if it is zero then you know that myMapping[key] doesn't yet exist
        if(myMapping[key].seatNumber != 0) {
            return true;
        } 
        return false;
    }

    function add(string memory key, uint seatNumber) public returns (bool){            
        myMapping[key].seatNumber = seatNumber;            
        return true;
    }
}




Javascript

Related
capturar el id de un elemento con jquery Code Example capturar el id de un elemento con jquery Code Example
repeat a block as many times as a nember jsx Code Example repeat a block as many times as a nember jsx Code Example
how to read from asset in angular Code Example how to read from asset in angular Code Example
concept of node js with react js Code Example concept of node js with react js Code Example
toggle text on click in angular Code Example toggle text on click in angular Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
9