I am new to Solidity, and I have a small problem. For exemple I have these 2 contracts
contract Dog {
string name;
constructor(string _name){
name = _name;
}
}
contract Human {
Dog[] dogs;
uint currDogs = 0;
function addDog() public {
dogs[currDogs] = new Dog("test");
//I also tried dogs.push(new Dog("test"));
currDogs++;
}
}
everytime I try adding a dog to the array it is not working and I can't find a solution
EDIT: thanks guys, all the answwersanswers are correct, even my code is working fine, I found out that I was re deploying the contract everytime, that's why my changes are not getting saved.