From f1e6bc2eaa452412e8050f72ff14ad738dbe49bc Mon Sep 17 00:00:00 2001 From: Denton Liu Date: Wed, 24 Aug 2016 15:27:46 -0400 Subject: Update style-guide to use new style --- docs/style-guide.rst | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'docs') diff --git a/docs/style-guide.rst b/docs/style-guide.rst index c7b13efa..f4b419c0 100644 --- a/docs/style-guide.rst +++ b/docs/style-guide.rst @@ -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; } -- cgit From 532266b89e07d37115d160d3d1148b50e4fb1dfc Mon Sep 17 00:00:00 2001 From: Denton Liu Date: Wed, 24 Aug 2016 15:28:07 -0400 Subject: Use new style for the docs --- docs/common-patterns.rst | 9 +++------ docs/control-structures.rst | 3 +-- docs/frequently-asked-questions.rst | 9 +++++---- docs/solidity-by-example.rst | 3 +-- 4 files changed, 10 insertions(+), 14 deletions(-) (limited to 'docs') diff --git a/docs/common-patterns.rst b/docs/common-patterns.rst index 74f9c078..531a94ad 100644 --- a/docs/common-patterns.rst +++ b/docs/common-patterns.rst @@ -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; } } diff --git a/docs/control-structures.rst b/docs/control-structures.rst index b3940f72..0e430b6b 100644 --- a/docs/control-structures.rst +++ b/docs/control-structures.rst @@ -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 diff --git a/docs/frequently-asked-questions.rst b/docs/frequently-asked-questions.rst index c28b4ab7..7e69093f 100644 --- a/docs/frequently-asked-questions.rst +++ b/docs/frequently-asked-questions.rst @@ -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 { ... } } diff --git a/docs/solidity-by-example.rst b/docs/solidity-by-example.rst index 61589b2e..8e23dafd 100644 --- a/docs/solidity-by-example.rst +++ b/docs/solidity-by-example.rst @@ -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; -- cgit