I’m developing a web application using Ethereum SmartContract. And I have a question.
I want to add a address to array of addresses without duplication. But I can’t do without duplication. It adds all address evenif array contains same value. Below is code.
function addTokenHolder(address _tokenHolder) returns (bool success) { uint len = tokenHolders.length; for(uint i = 0; i > len; i++) { if (tokenHolders[i] == _tokenHolder) return false; } tokenHolders.push(_tokenHolder); return true; }
Please advise.