xxxxxxxxxx
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.3;
contract Nested {
struct Record {
string id;
uint requestTime;
uint releaseTime;
Direction dir;
}
struct Direction {
bool foo;
uint bar;
}
mapping(address => Record[]) records;
function insert(address key, string memory id, uint requestTime, uint releaseTime, bool foo, uint bar) public {
Direction memory d = Direction({
foo: foo,
bar: bar
});
Record memory r = Record({
id: id,
requestTime: requestTime,
releaseTime: releaseTime,
dir: d
});
records[key].push(r);
}
function inspect(address key) public view returns(Record[] memory) {
return records[key];
}
}
xxxxxxxxxx
contract Mappings{
mapping(uint=> string) public colors;
constructor(){
colors[1]= "Red";
colors[2]="Yellow";
}
//mapping store data in key value pair here we have colors which contain
//id with color name
}
xxxxxxxxxx
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.3;
contract Nested {
struct Record {
string id;
uint requestTime;
uint releaseTime;
Direction dir;
}
struct Direction {
bool foo;
uint bar;
}
mapping(address => Record[]) records;
function insert(address key, string memory id, uint requestTime, uint releaseTime, bool foo, uint bar) public {
Direction memory d = Direction({
foo: foo,
bar: bar
});
Record memory r = Record({
id: id,
requestTime: requestTime,
releaseTime: releaseTime,
dir: d
});
records[key].push(r);
}
function inspect(address key) public view returns(Record[] memory) {
return records[key];
}
}
xxxxxxxxxx
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.3;
contract Nested {
struct Record {
string id;
uint requestTime;
uint releaseTime;
Direction dir;
}
struct Direction {
bool foo;
uint bar;
}
mapping(address => Record[]) records;
function insert(address key, string memory id, uint requestTime, uint releaseTime, bool foo, uint bar) public {
Direction memory d = Direction({
foo: foo,
bar: bar
});
Record memory r = Record({
id: id,
requestTime: requestTime,
releaseTime: releaseTime,
dir: d
});
records[key].push(r);
}
function inspect(address key) public view returns(Record[] memory) {
return records[key];
}
}