diff --git a/docs/control-structures.rst b/docs/control-structures.rst index 85e594707..bd04ce58b 100644 --- a/docs/control-structures.rst +++ b/docs/control-structures.rst @@ -298,8 +298,8 @@ Scoping and Declarations A variable which is declared will have an initial default value whose byte-representation is all zeros. The "default values" of variables are the typical "zero-state" of whatever the type is. For example, the default value for a ``bool`` is ``false``. The default value for the ``uint`` or ``int`` types is ``0``. For statically-sized arrays and ``bytes1`` to ``bytes32``, each individual -element will be initialized to the default value corresponding to its type. Finally, for dynamically-sized arrays, ``bytes`` -and ``string``, the default value is an empty array or string. +element will be initialized to the default value corresponding to its type. For dynamically-sized arrays, ``bytes`` +and ``string``, the default value is an empty array or string. For the ``enum`` type, the default value is its first member. Scoping in Solidity follows the widespread scoping rules of C99 (and many other languages): Variables are visible from the point right after their declaration diff --git a/docs/examples/safe-remote.rst b/docs/examples/safe-remote.rst index 765bdfc35..c4e684ce1 100644 --- a/docs/examples/safe-remote.rst +++ b/docs/examples/safe-remote.rst @@ -13,6 +13,7 @@ Safe Remote Purchase address payable public seller; address payable public buyer; enum State { Created, Locked, Inactive } + // The state variable has a default value of the first member, `State.created` State public state; // Ensure that `msg.value` is an even number. diff --git a/docs/types/value-types.rst b/docs/types/value-types.rst index b8d67399a..f970a2e2c 100644 --- a/docs/types/value-types.rst +++ b/docs/types/value-types.rst @@ -512,7 +512,7 @@ Enums Enums are one way to create a user-defined type in Solidity. They are explicitly convertible to and from all integer types but implicit conversion is not allowed. The explicit conversion from integer checks at runtime that the value lies inside the range of the enum and causes a failing assert otherwise. -Enums needs at least one member. +Enums require at least one member, and its default value when declared is the first member. The data representation is the same as for enums in C: The options are represented by subsequent unsigned integer values starting from ``0``.