bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: delete of nested array is in consistent


From: Andrew J. Schorr
Subject: Re: delete of nested array is in consistent
Date: Thu, 16 Apr 2020 21:11:55 -0400
User-agent: Mutt/1.5.21 (2010-09-15)

Hi,

On Thu, Apr 16, 2020 at 04:05:08PM -0700, david kerns wrote:
> pretty sure gawk still doesn't have "true" multi-dimensional arrays...

It does have true multi-dimensional arrays. This has been available
since at least version 4.0.0. From the NEWS for 4.0.0:

30. A new isarray() function exists to distinguish if an item is an array
    or not, to make it possible to traverse multidimensional arrays.

The isarray code dates to 2011, so this feature has been in gawk
for a long time.

The documentation about SUBSEP is perhaps a bit misleading.
If you access x[a, b], then it's a "fake" multidimensional array.
But if you use x[a][b], it's truly multidimensional. In the gawk docs,
these are called arrays of arrays:

https://www.gnu.org/software/gawk/manual/html_node/Arrays-of-Arrays.html

   'gawk' goes beyond standard 'awk''s multidimensional array access and
   provides true arrays of arrays.  Elements of a subarray are referred to
   by their own indices enclosed in square brackets, just like the elements
   of the main array.  For example, the following creates a two-element
   subarray at index '1' of the main array 'a':

        a[1][1] = 1
        a[1][2] = 2

Regards,
Andy



reply via email to

[Prev in Thread] Current Thread [Next in Thread]