Skip to content

Commit

Permalink
update static
Browse files Browse the repository at this point in the history
  • Loading branch information
xhliu committed Aug 27, 2021
1 parent c9c3dfd commit 824cd96
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions docs/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,22 @@ is functionally equivalent to
static function and property
----------------------------
A static function/property can be referenced with contract name without an instantiated contract, similar to a static function/property in Javascript or C++.
A static property can also be referenced without the contract prefix, but only in the contract it is defined in.
A static property/function can be referenced with contract name as prefix without an instantiated contract, similar to a static function/property in Javascript or C++.
A static property/function can also be referenced without the contract prefix, but only in the contract it is defined in.

.. code-block:: solidity
contract Foo {
int i;
library Foo {
static int N = 0;
static function incByN(int a): int {
// N is used without Foo prefix
return a + N;
// N is used with and without Foo prefix
return a + Foo.N + N;
}
static function double(int x): int {
// N is used with Foo prefix
return Foo.incByN(x) + this.i + Foo.N;
// incByN() is called with prefix and without
return Foo.incByN(x) + incByN(x);
}
}
Expand Down

0 comments on commit 824cd96

Please sign in to comment.