我想创建一个带有结构体数组的 Pokémon 结构。
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
contract PokemonFactory {
struct Pokemon {
uint256 id;
string name;
Ability[] abilities;
}
struct Ability {
string name;
string description;
}
Pokemon[] public pokemons;
function createPokemon(string memory _name, string memory _abilityNme, string memory _abilityDscription) public {
uint id = pokemons.length;
pokemons[id].abilities.push(Ability(_abilityNme, _abilityDscription));
pokemons.push(Pokemon(id, _name, pokemons[id].abilities));
}
}
但我遇到了以下错误:
UnimplementedFeatureError: Copying of type struct PokemonFactory.Ability memory[] memory to storage not yet supported.