Consider the following contract in Solidity:
pragma solidity ^0.4.2;
contract Registry {
struct Name {
string first;
string last;
}
mapping(address => Name) reg;
function newName(string first, string last) {
address sender = msg.sender;
if(reg[sender] != 0) {
throw;
}
reg[sender].first = first;
reg[sender].last = last;
}
}
In the if
statement above, which is incorrect, I would like to check whether the struct Name
is defined, or is still in the default value with all fields initialized to zero. Is there a language operator to do it?