codedamn

Dynamic Size Array

Created by Kshitij about a year ago

0

No description provided

6 Comments

    0

    Can we pop element based on index. I checked in solidity documentation but couldnot find such.

    @kalitaking

    deepankar kalita

    @kalitaking

    0

    sir is there a way to insert elements at a particular index eg.inserting 10 in position 2 of the array

    @harimenon0143

    Hari Menon

    @harimenon0143

    0

    Getting error when trying to pop element from array. Attaching my code and error message.

    // SPDX-License-Identifier: MIT

    pragma solidity >=0.5.0 <0.9.0;

    contract Array{

    uint[] public arr;
    
    function pushElement(uint element) public {
        arr.push(element);
    }
    
    function popElement() public {
        arr.pop();
    }
    
    function len() public view returns(uint){
        return arr.length;
    }
    

    }

    Error Message

    transact to Array.popElement pending ...

    transact to Array.popElement errored: VM error: out of gas.

    out of gas

    The transaction ran out of gas. Please increase the Gas Limit.
    

    Debug the transaction to get more information.

    @manditim

    Manideep Paul

    @manditim

    0

    I think Reverse array practice program should be given after loops since it uses dynamic array and for-loop which is taught laterly.

    @nikhil62755443

    Nikhil Mukati

    @nikhil62755443

    0

    Sir kindly explain me. why we use here memory keyword with uint? I understand that we have to use it with String data type but why uint keyword? uint data type give us a number. 😕

    @muhamm643c5e3b

    Muhammad Umair

    @muhamm643c5e3b

    0

    Thanks you Sir

    @muhamm643c5e3b

    Muhammad Umair

    @muhamm643c5e3b

Your comment