In the function registerUser
below, I am trying to access a global array of structs, and seeing if the argument I have passed exists in the global array or not. The code is as follows:
user_details[] user_list; //The global array
function registerUser(user_details memory _user) public {
// check if user does not exist
bool found = false;
for (uint i = 0; i < user_list.length; i++) {
if (user_list[i] == _user)
found = true;
}
}
However, it is giving me the following error:
Operator == not compatible with types struct LandInit.user_details storage ref and struct LandInit.user_details storage pointer
Is there a possibility of casting ref as pointer? Or any other fix? I tried creating new struct in the function and copying the function argument to it, but it still gives an error.