[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug-gawk] typeof() array subscripts
From: |
Hermann Peifer |
Subject: |
[bug-gawk] typeof() array subscripts |
Date: |
Sat, 20 Jun 2015 13:23:22 +0200 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 |
Hi again,
I just came across the new builtin function typeof() in gawk master and
made the below observations which I found confusing, because "array
subscripts are always strings", as I learned from the manual. Maybe I am
overlooking something.
Hermann
# These subscripts are numbers, rather than the expected strings.
$ awk 'BEGIN{ a[1]; a[2]; for (i in a) print i, typeof(i) }'
1 scalar_n
2 scalar_n
# Same here...
$ awk 'BEGIN{ a["1"]; a["2"]; for (i in a) print i, typeof(i) }'
1 scalar_n
2 scalar_n
# One number and one string
$ awk 'BEGIN{ a["1"]; a["x"]; for (i in a) print i, typeof(i) }'
x scalar_s
1 scalar_n
# Why 2 strings in the below case?
$ awk 'BEGIN{ a["x"]; a["1"]; for (i in a) print i, typeof(i) }'
x scalar_s
1 scalar_s
- [bug-gawk] typeof() array subscripts,
Hermann Peifer <=