What dose the -1 means? Or why we should use -1 while pushing one element in array. What should I enter in sellerAccounts: field as input?

pragma solidity ^0.5.1;

contract Seller{

    struct Sellers{
        uint sellerId;
        address sellerAddress;
        string sellerName;
    mapping (address => Sellers) sellerStruct;
    address[] public sellerAccounts;

   function setSeller(address _address, uint _seller_id, string memory _seller_name) public{
        Sellers memory sellerVar = sellerStruct[_address];
        sellerVar.sellerId = _seller_id;
        sellerVar.sellerName = _seller_name;
        sellerAccounts.push(_address) -1;

What should I enter in this field as input?


The value of the expression sellerAccounts.push(_address) -1 is equal to the length of the sellerAccounts array prior the push operation.

Since you are not storing this value anywhere, this expression has no impact whatsoever (though it might yield an extra gas cost when the function is executed), and it can therefore be removed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.