contract Shopping {
struct Article {
uint id;
address seller;
address buyer;
string name;
string description;
uint256 price;
}
// state variable
mapping(uint256 => Article) public articles;
uint articleCounter;
function buyArticle(uint _id ) public payable {
Article storage article = articles[_id];
require( article.buyer == 0x0);
require(msg.sender != article .seller]);
}
}
1) I have got this code in online
2) i am wondering why storage is declared rather than memory
3) For getting values from mapping articles[] i used slicing technique which is similar to array slicing
4) But Now in storage type we are using article.buyer rather than article[buyer]