Question : solidity check if array contains
Answered by : john-appleseed
// either use a mapping
mapping(address => uint8) myMap;
// write a for loop (try not to do this unless have to)
// try not to use less or equal to, use less instead
// gas optimisation
for (uint256 i = 0; i < 1; i++) { if (searchList[i] == "toFindString") { // do whatever break; }
}
Source : | Last Update : Sat, 30 Apr 22