mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #960 from Denton-L/change-else-style
Change else style
This commit is contained in:
commit
18abafe029
@ -45,8 +45,7 @@ become the new richest.
|
||||
richest = msg.sender;
|
||||
mostSent = msg.value;
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -58,8 +57,7 @@ become the new richest.
|
||||
pendingWithdrawals[msg.sender] = 0;
|
||||
if (msg.sender.send(amount)) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
pendingWithdrawals[msg.sender] = amount;
|
||||
return false;
|
||||
}
|
||||
@ -90,8 +88,7 @@ This is as opposed to the more intuitive sending pattern.
|
||||
richest = msg.sender;
|
||||
mostSent = msg.value;
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -275,8 +275,7 @@ As a result, the following code is legal, despite being poorly written::
|
||||
uint bar = 5;
|
||||
if (true) {
|
||||
bar += baz;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
uint baz = 10;// never executes
|
||||
}
|
||||
return bar;// returns 5
|
||||
|
@ -461,16 +461,17 @@ If you do not want to throw, you can return a pair::
|
||||
|
||||
function getCounter(uint index)
|
||||
returns (uint counter, bool error) {
|
||||
if (index >= counters.length) return (0, true);
|
||||
else return (counters[index], false);
|
||||
if (index >= counters.length)
|
||||
return (0, true);
|
||||
else
|
||||
return (counters[index], false);
|
||||
}
|
||||
|
||||
function checkCounter(uint index) {
|
||||
var (counter, error) = getCounter(index);
|
||||
if (error) {
|
||||
...
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
...
|
||||
}
|
||||
}
|
||||
|
@ -133,8 +133,7 @@ of votes.
|
||||
// If the delegate already voted,
|
||||
// directly add to the number of votes
|
||||
proposals[delegate.vote].voteCount += sender.weight;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// If the delegate did not vote yet,
|
||||
// add to her weight.
|
||||
delegate.weight += sender.weight;
|
||||
|
@ -273,17 +273,17 @@ No::
|
||||
}));
|
||||
|
||||
For ``if`` blocks which have an ``else`` or ``else if`` clause, the ``else`` should be
|
||||
placed on it's own line following the previous closing parenthesis. The
|
||||
parenthesis for the else block should follow the same rules as the other
|
||||
conditional control structures.
|
||||
placed on the same line as the ``if``'s closing brace. This is an exception compared
|
||||
to the rules of other block-like structures.
|
||||
|
||||
Yes::
|
||||
|
||||
if (x < 3) {
|
||||
x += 1;
|
||||
}
|
||||
else {
|
||||
} else if (x > 7) {
|
||||
x -= 1;
|
||||
} else {
|
||||
x = 5;
|
||||
}
|
||||
|
||||
|
||||
@ -296,7 +296,8 @@ No::
|
||||
|
||||
if (x < 3) {
|
||||
x += 1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
x -= 1;
|
||||
}
|
||||
|
||||
|
@ -17,8 +17,7 @@ contract StandardToken is Token {
|
||||
balanceOf[_to] += _value;
|
||||
Transfer(msg.sender, _to, _value);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -29,8 +28,7 @@ contract StandardToken is Token {
|
||||
balanceOf[_to] += _value;
|
||||
Transfer(_from, _to, _value);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -130,9 +130,7 @@ contract GlobalRegistrar is Registrar, AuctionSystem {
|
||||
if (previousOwner != 0) {
|
||||
if (!record.owner.send(auction.sumOfBids - auction.highestBid / 100))
|
||||
throw;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
if (!auction.highestBidder.send(auction.highestBid - auction.secondHighestBid))
|
||||
throw;
|
||||
}
|
||||
@ -147,9 +145,7 @@ contract GlobalRegistrar is Registrar, AuctionSystem {
|
||||
if (now < m_toRecord[_name].renewalDate)
|
||||
throw;
|
||||
bid(_name, msg.sender, msg.value);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
Record record = m_toRecord[_name];
|
||||
if (record.owner != 0)
|
||||
throw;
|
||||
|
@ -2563,8 +2563,9 @@ BOOST_AUTO_TEST_CASE(event)
|
||||
if (_manually) {
|
||||
bytes32 s = 0x19dacbf83c5de6658e14cbf7bcae5c15eca2eedecf1c66fbca928e4d351bea0f;
|
||||
log3(bytes32(msg.value), s, bytes32(msg.sender), _id);
|
||||
} else
|
||||
} else {
|
||||
Deposit(msg.sender, _id, msg.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
)";
|
||||
|
@ -540,7 +540,7 @@ BOOST_AUTO_TEST_CASE(if_statement)
|
||||
{
|
||||
char const* text = "contract test {\n"
|
||||
" function fun(uint256 a) {\n"
|
||||
" if (a >= 8) return 2; else { var b = 7; }\n"
|
||||
" if (a >= 8) { return 2; } else { var b = 7; }\n"
|
||||
" }\n"
|
||||
"}\n";
|
||||
BOOST_CHECK(successParse(text));
|
||||
|
Loading…
Reference in New Issue
Block a user