Documents shortcut array syntax. Refs #397.
This commit is contained in:
parent
a7e70e6229
commit
19a36c9acb
1 changed files with 15 additions and 0 deletions
15
doc/tut1.txt
15
doc/tut1.txt
|
|
@ -1182,6 +1182,21 @@ type and instead write it embedded directly as the type of the first dimension:
|
||||||
type
|
type
|
||||||
TLightTower = array[1..10, array[north..west, TBlinkLights]]
|
TLightTower = array[1..10, array[north..west, TBlinkLights]]
|
||||||
|
|
||||||
|
It is quite frequent to have arrays start at zero, so there's a shortcut syntax
|
||||||
|
to specify a range from zero to the specified index minus one:
|
||||||
|
|
||||||
|
.. code-block:: nimrod
|
||||||
|
type
|
||||||
|
TIntArray = array[0..5, int] # an array that is indexed with 0..5
|
||||||
|
TQuickArray = array[6, int] # an array that is indexed with 0..5
|
||||||
|
var
|
||||||
|
x: TIntArray
|
||||||
|
y: TQuickArray
|
||||||
|
x = [1, 2, 3, 4, 5, 6]
|
||||||
|
y = x
|
||||||
|
for i in low(x)..high(x):
|
||||||
|
echo(x[i], y[i])
|
||||||
|
|
||||||
|
|
||||||
Sequences
|
Sequences
|
||||||
---------
|
---------
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue