Skip to content

Commit

Permalink
const
Browse files Browse the repository at this point in the history
  • Loading branch information
xhliu committed Jan 20, 2021
1 parent 86dd677 commit dd25c04
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions docs/syntax.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ Array Types
-----------
An array is a fixed-size list of values of the same basic type [#]_.

* **Array Literals** - a comma-separated list of expressions, enclosed in square brackets.
Array size must be an integer constant greater than zero.
* **Array Literals** - a comma-separated list of expressions, enclosed in square brackets. Array size must be an integer constant greater than zero.

.. code-block:: solidity
Expand Down Expand Up @@ -123,6 +122,29 @@ The ``auto`` keyword specifies that the type of the variable, of basic type, dec
auto a1 = b'36'; // bytes a1 = b'36';
auto a2 = 1 + 5 * 3; // int a2 = 1 + 5 * 3;
``const`` Variables
===================
Variables declared const cannot be changed once initialized.

.. code-block:: solidity
contract Test {
const int x;
constructor(int x) {
this.x = x; // good, since this is initialization
}
public function equal(const int y) {
y = 1; // <-- error
const int a = 36;
a = 11; // <-- error
require(y == this.x);
}
}
Domain Subtypes
===============
There are several subtypes, specific to the Bitcoin context, used to further improve type safety.
Expand Down

0 comments on commit dd25c04

Please sign in to comment.