aboutsummaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to 'docs')
-rw-r--r--docs/common-patterns.rst9
-rw-r--r--docs/control-structures.rst3
-rw-r--r--docs/frequently-asked-questions.rst9
-rw-r--r--docs/solidity-by-example.rst3
-rw-r--r--docs/style-guide.rst13
5 files changed, 17 insertions, 20 deletions
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;
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;
}