I'm trying to return a struct called Trainer from a mapping of addresses -> Trainer
Is there any way to easily retrieve the Trainer struct from the trainersMap?
struct Trainer {
address owner;
string name;
Pokemon[] pokemons;
}
mapping(address => Trainer) public trainersMap;
function getTrainer() public {
address sender = msg.sender;
return Trainer(sender, trainersMap[sender].name, trainersMap[sender].pokemons);
// I tried this
// return trainersMap[sender]
}
Pokemon
? Is it a struct?