Hi can some one tell me if the below notations and their naming conventions are correct if wrong kindly please do provide an explanation.
a4
is not a regular 2D array. It is a Dynamic array of dynamic arrays. Each dynamic array can have a different size.
a4 = new[4];
foreach (a4[i]) a4[i] = new[i+1];
Also, use a datatype like int
instead of $
when declaring an associative array. You cannot iterate when over the index $
because it has no type.
Hi @dave_59,
Are not the comments in the example wrong?
$ - is used for arrays which are queues.
* - is used for arrays which its index could be any integral expression.
SV queue (FROM SV LRM):
Associative arrays (From SV LRM):
So how come:
int a1[4][$];
Is a “Fixed array of associative array”, and not a “Fixed array of queues”?
BTW, I saw the words “associative array” and mixed up $
for *
.
Of course [$]
is for queues and and [*]
is a wildcard associative array. Sorry for the confusion.
So the $ in the quote above meant to be * ?
Correct, I should have said:
Also, use a datatype like [int]
instead of [*]
when declaring an associative array. You cannot iterate when over the index [*]
because it has no type.