{ "error": "wasm execution failed with error: FunctionCallError(HostError(GuestPanic { panic_msg: "Element type must be nullable if array is holey, filename: \"~lib/array.ts\" line: 103 col: 40" }))", "logs": [], "block_height": 82571830, "block_hash": "2grrzf57dPYQfnyUJZB7jw2zdqe7XsxBZBAdoSZ5wNMa" }
Code
for(let i:i32 =0 ; i < reviews.length ; i++)
{
let condition = reviews[i].restaurant.restaurant_name==restaurantName;
if(condition)
{
reviews_[i] = reviews[i].review;
}
}
return reviews_;
}
I think this function will create "holes" in the array because of the condition in your for loop. Instead of using the same length for
reviews_
andreviews
, you could create an emptyreviews_
array, and push elements to it instead (see example,getShortList
, below)Having a holey list will look something like this
Instead of having unknown elements, you either have to fill the blanks with a
null
-able elements, e.g. an empty reviewOr just make sure the list only contains elements without any "holes" in the array (a "packed" array)
Consider the following example