From 0d4adc44c9ef269b81f42fc56658a7b0e1f3156c Mon Sep 17 00:00:00 2001 From: Daniel Kronovet Date: Sun, 3 Jun 2018 12:25:52 +0300 Subject: [PATCH 1/2] Update function visibility example Two functions don't access state and should be `pure`. Also, inconsistent spacing when using arithmetic. --- docs/contracts.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/contracts.rst b/docs/contracts.rst index a083b9e98..fa6b45646 100644 --- a/docs/contracts.rst +++ b/docs/contracts.rst @@ -194,10 +194,10 @@ In the following example, ``D``, can call ``c.getData()`` to retrieve the value contract C { uint private data; - function f(uint a) private returns(uint b) { return a + 1; } + function f(uint a) private pure returns(uint b) { return a + 1; } function setData(uint a) public { data = a; } function getData() public returns(uint) { return data; } - function compute(uint a, uint b) internal returns (uint) { return a+b; } + function compute(uint a, uint b) internal pure returns (uint) { return a + b; } } contract D { From 1a603625d49d615b883118b083b1b962ba7e64f7 Mon Sep 17 00:00:00 2001 From: Daniel Kronovet Date: Mon, 4 Jun 2018 15:00:55 +0300 Subject: [PATCH 2/2] Denote `getData` as view --- docs/contracts.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/contracts.rst b/docs/contracts.rst index fa6b45646..3d6ee869e 100644 --- a/docs/contracts.rst +++ b/docs/contracts.rst @@ -196,7 +196,7 @@ In the following example, ``D``, can call ``c.getData()`` to retrieve the value function f(uint a) private pure returns(uint b) { return a + 1; } function setData(uint a) public { data = a; } - function getData() public returns(uint) { return data; } + function getData() public view returns(uint) { return data; } function compute(uint a, uint b) internal pure returns (uint) { return a + b; } }