|
Oktatás * Programozás 1 * Szkriptnyelvek Teaching • Programming 1 (BI) Félévek Linkek * kalendárium |
Nim2 /
Static arraysNim has both static arrays (like in C) and dynamic arrays (like in Python). This time, let's see the static arrays. Static arrays are fixed-sized arrays. Their size is decided upon creation and later it cannot be changed. A static array cannot grow or shrink.
Since these arrays are Specify the index rangeThe indexing doesn't have to start with 0. When you create a static array, you can specify the index range: var a: array[1..5, int] # filled with 0s a[1] = 1 a[3] = 1 a[5] = 1 echo a # [1, 0, 1, 0, 1] #echo a[0] # ERROR: invalid index 𝥶Now, indexing starts with 1 and the highest index is 5. |
![]() Blogjaim, hobbi projektjeim * The Ubuntu Incident [ edit ] |
||||