Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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;
    }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: jquery code to javascript converter 
Javascript :: array name in id fields 
Javascript :: requiere and get a property simplified with Node 
Javascript :: setEventListeners form inputs 
Javascript :: how to write in uft-8 in write json file python 
Javascript :: .localecompare number func 
Javascript :: cannot Nesting classes sass nextjs 
Javascript :: GetNameOfZone 
Javascript :: how to get current row value by clicking a button 
Javascript :: circle rect collision 
Javascript :: create immutable array in javascript 
Javascript :: ingore render on refresh page 
Javascript :: how to make image slider in react js 
Javascript :: simple promise 
Javascript :: trigger many calls JS 
Javascript :: find invalid json files in directory 
Javascript :: where to make the hooks functions 
Javascript :: slice method javascript 
Javascript :: simple method 
Javascript :: express pass data between middleware 
Javascript :: openapi 3 json and file 400 
Javascript :: nyaapi node 
Javascript :: show capture of createCapture p5 js 
Javascript :: npm resize div 
Javascript :: how to add heaeader to http angular client 
Javascript :: JavaScript Normalized and UnNnormalized URL 
Javascript :: How to get element margin in React 
Javascript :: convert java object to json 
Javascript :: reset default style javascript 
Javascript :: js shufflin 
ADD CONTENT
Topic
Content
Source link
Name
4+6 =