[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: associative arrays get entries added, apparently from test
From: |
Aharon Robbins |
Subject: |
Re: associative arrays get entries added, apparently from test |
Date: |
Mon, 05 Dec 2005 22:18:21 +0200 |
Greetings. I didn't open your file, but you undoubtedly mean
that something like
if (x[subscript]) ...
creates an element with an empty value if it wasn't there before.
This is the documented behavior. What you probably want is
if (subscript in x) ....
which tests if the subscript exists without creating the element.
This is documented in the gawk manual.
HTH,
Arnold
> Date: Wed, 30 Nov 2005 14:26:16 -0700
> From: "Marcus G. Daniels" <address@hidden>
> Subject: associative arrays get entries added, apparently from test
> To: address@hidden
>
> Hello,
>
> If the script `test' in the attached archive is run, the result "should
> not happen" is reported.
> The cause seems to be the line "if (origNames[peptide])" which has the
> side-effect of adding an entry in the iteration over origNames in the
> END clause. In other words, the associative array `origNames' gets
> extra entries added that it should not.
>
> Please let me know if this explanation isn't clear.
>
> Best,
>
> Marcus Daniels
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: associative arrays get entries added, apparently from test,
Aharon Robbins <=