I'm trying to create a mapping whit this structure:
mapping(string => House) public houses;
where House is a Struct:
struct House {
address payable owner;
uint256 base_price;
}
I already have an array where I store all the strings that I want in my mapping keys, lets say something like this:
string[] public cities = ["New York", "Las Vegas", "London", "Paris", "Moscow"];
The only exception is that my array is much longer (250 elements) and I wanted to know if it'd possible to create the mapping without looping through the array using something like a map function in javascript giving to all of the initial element the same starting Struct.
At the moment I'm doing it like this:
for (uint i=0; i<cities.length; i++) {
houses[cities[i]] = House(payable(0), 0.0005 ether, "");
}
Is there a more efficient way of doing this? Thank you in advance.