Ok, here's the code from solidity docs:
contract Sharer {
function sendHalf(address addr) returns (uint balance) {
if (!addr.send(msg.value / 2))
throw; // also reverts the transfer to Sharer
return this.balance;
}
}
My problem with this example is the comment:
// also reverts the transfer to Sharer
It's confusing, because throw
in my understanding reverts the transfer to the msg.sender and Sharer contract isn't the msg.sender here. What am I missing here?
Wouldn't it be les confusing if the code was changed to this:
contract Sharer {
function sendHalf(address addr) returns (uint balance) {
if (!addr.send(msg.value / 2)) // if false reverts the transfer to Sharer
throw; // reverts the transfer to msg.sender
return this.balance;
}
}