pragma solidity ^0.8.0;
contract Crud {
struct Users{
uint id;
string name;
}
Users[] users; // this is type storage
uint length = 0;
function addUser(string memory _name) public{
users.push(Users(length,_name));
length++;
}
function getUser(uint _index) view public returns(Users memory){
return users[_index];
}
}
I have this basic code.
In getUser function why is it expecting the return type of Users as memory? It will return users and that is type storage.