mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
docs/
Enhancing all the .rst doc files by adding highlighting for the code snippets, including the following langs: 1. Solidity 2. bash 3. javascript 4. assembly
This commit is contained in:
@@ -60,7 +60,7 @@ Data locations are not only relevant for persistency of data, but also for the s
|
||||
variables of storage struct type, even if the local variable
|
||||
itself is just a reference.
|
||||
|
||||
::
|
||||
.. code-block:: solidity
|
||||
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
pragma solidity >=0.5.0 <0.9.0;
|
||||
@@ -171,7 +171,7 @@ You can concatenate a variable number of ``bytes`` or ``bytes1 ... bytes32`` usi
|
||||
The function returns a single ``bytes memory`` array that contains the contents of the arguments without padding.
|
||||
If you want to use string parameters or other types, you need to convert them to ``bytes`` or ``bytes1``/.../``bytes32`` first.
|
||||
|
||||
::
|
||||
.. code-block:: solidity
|
||||
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
pragma solidity ^0.8.4;
|
||||
@@ -200,7 +200,7 @@ or create a new memory array and copy every element.
|
||||
As all variables in Solidity, the elements of newly allocated arrays are always initialized
|
||||
with the :ref:`default value<default-value>`.
|
||||
|
||||
::
|
||||
.. code-block:: solidity
|
||||
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
pragma solidity >=0.4.16 <0.9.0;
|
||||
@@ -239,7 +239,7 @@ In the example below, the type of ``[1, 2, 3]`` is
|
||||
you want the result to be a ``uint[3] memory`` type, you need to convert
|
||||
the first element to ``uint``.
|
||||
|
||||
::
|
||||
.. code-block:: solidity
|
||||
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
pragma solidity >=0.4.16 <0.9.0;
|
||||
@@ -261,7 +261,7 @@ Since fixed-size memory arrays of different type cannot be converted into each o
|
||||
(even if the base types can), you always have to specify a common base type explicitly
|
||||
if you want to use two-dimensional array literals:
|
||||
|
||||
::
|
||||
.. code-block:: solidity
|
||||
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
pragma solidity >=0.4.16 <0.9.0;
|
||||
@@ -278,7 +278,7 @@ if you want to use two-dimensional array literals:
|
||||
Fixed size memory arrays cannot be assigned to dynamically-sized
|
||||
memory arrays, i.e. the following is not possible:
|
||||
|
||||
::
|
||||
.. code-block:: solidity
|
||||
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
pragma solidity >=0.4.0 <0.9.0;
|
||||
@@ -298,7 +298,7 @@ complications because of how arrays are passed in the ABI.
|
||||
If you want to initialize dynamically-sized arrays, you have to assign the
|
||||
individual elements:
|
||||
|
||||
::
|
||||
.. code-block:: solidity
|
||||
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
pragma solidity >=0.4.16 <0.9.0;
|
||||
@@ -356,7 +356,7 @@ Array Members
|
||||
that return dynamic arrays, make sure to use an EVM that is set to
|
||||
Byzantium mode.
|
||||
|
||||
::
|
||||
.. code-block:: solidity
|
||||
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
pragma solidity >=0.6.0 <0.9.0;
|
||||
@@ -489,7 +489,7 @@ they only exist in intermediate expressions.
|
||||
|
||||
Array slices are useful to ABI-decode secondary data passed in function parameters:
|
||||
|
||||
::
|
||||
.. code-block:: solidity
|
||||
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
pragma solidity >0.8.4 <0.9.0;
|
||||
@@ -528,7 +528,7 @@ Structs
|
||||
Solidity provides a way to define new types in the form of structs, which is
|
||||
shown in the following example:
|
||||
|
||||
::
|
||||
.. code-block:: solidity
|
||||
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
pragma solidity >=0.6.0 <0.9.0;
|
||||
|
||||
Reference in New Issue
Block a user