// SPDX-License-Identifier:GPL-30
pragma solidity >= 0.7.0 < 0.9.0;
contract lec20{
struct Character{
uint256 age;
string name;
string job;
}
}
// SPDX-License-Identifier:GPL-30
pragma solidity >= 0.7.0 < 0.9.0;
contract lec20{
struct Character{
uint256 age;
string name;
string job;
}
function createCharacter(uint256 _age,string memory _name,string memory _job) public pure{
Character(_age,_name,_job);
}
}
// SPDX-License-Identifier:GPL-30
pragma solidity >= 0.7.0 < 0.9.0;
contract lec20{
struct Character{
uint256 age;
string name;
string job;
}
mapping(uint256=>Character) public CharacterMapping;
Character[] public CharacterArray;
}
// SPDX-License-Identifier:GPL-30
pragma solidity >= 0.7.0 < 0.9.0;
contract lec20{
struct Character{
uint256 age;
string name;
string job;
}
mapping(uint256=>Character) public CharacterMapping;
Character[] public CharacterArray;
function createCharacter(uint256 _age,string memory _name,string memory _job) pure public returns(Character memory) {
return Character(_age,_name,_job);
}
function createChracterMapping(uint256 _key, uint256 _age,string memory _name,string memory _job ) public {
CharacterMapping[_key] = Character(_age,_name,_job);
}
function getChracterMapping(uint256 _key) public view returns(Character memory){
return CharacterMapping[_key];
}
function createChracterArray(uint256 _age,string memory _name,string memory _job ) public {
CharacterArray.push(Character(_age,_name,_job));
}
function getChracterArray(uint256 _index) public view returns(Character memory){
return CharacterMapping[_index];
}
}
솔리디티 강좌 22강 loop (for,while,do-while) (0) | 2021.09.22 |
---|---|
솔리디티 강좌 21강 if 조건문 (0) | 2021.09.21 |
솔리디티 강좌 19강 Mapping 과 Array 주의할 점 (0) | 2021.09.19 |
솔리디티 강좌 18강 Array 배열 (0) | 2021.09.18 |
솔리디티 강좌 17강 Mapping (0) | 2021.09.17 |