[Top][All Lists]

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

Gawk Bug in arrays?

From: ghofulpo
Subject: Gawk Bug in arrays?
Date: Fri, 5 Nov 2010 12:11:44 -0700 (PDT)

Hi, I'm using Gawk 3.1.8, and if I run this:

    a[1] = "hi"
    if ( a[2] != "" ) print a[2]
    for ( inx in a )
        print inx " " a[inx]

I get:

bash-3.2$ gawk -f awkhate.awk
1 hi

The act of comparing a[2] (which should not exist) sets it to "".  I was 
mistakenly using this instead of a preferred:
if ( 2 in a )

However, I don't think that it should have behaved this way, regardless.

reply via email to

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