Member-only story

Solidity Tutorial: all about Array

Jean Cvllr
10 min readDec 25, 2019

--

In Solidity, an array is an ordered list of items that is indexed numerically, starting at 0.

Array types

In this section, we provide two types of categorisation for arrays:

  • Fixed-size vs dynamic size arrays
  • One-dimensional vs Multi-Dimensional arrays.

Fixed-size vs Dynamic-Size array

The Solidity documentation make the distinction between fixed-size and dynamic size arrays. In the examples below, T is the element type and k is the array length / size. If k = 5 , the array can hold a maximum of 5 values.

  • Fixed Size: T[k]
// array that can hold 5 unsigned integers maximumuint[5] my_array;
  • Dynamic Size: T[]
// array containing an undefined number of stringsstring[] my_array;

One Dimensional vs Multi-Dimensional arrays

One Dimensional and Multi-Dimensional arrays can be both of Fixed-Size or Dynamic-Size. The One Dimensional arrays are essentially the examples cited above. Here are the definitions

  • T[k] : One Dimensional, Fixed-size
  • T[] : One

--

--

Jean Cvllr
Jean Cvllr

Written by Jean Cvllr

Smart Contract engineer at @LUKSO. Full Stack Developer. https://github.com/CJ42

Responses (2)