[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug-gawk] Array literal
From: |
Steven Penny |
Subject: |
[bug-gawk] Array literal |
Date: |
Fri, 24 May 2019 20:36:29 -0700 (PDT) |
User-agent: |
Tryst/2.8.0 (cup.github.io/suede/tryst) |
Awk should have syntax for array literals. Currently if you wish to create an
array, you must use this:
dd[1] = "aa"
dd[2] = "bb"
dd[3] = "cc"
Or:
split("aa bb cc", dd)
the split syntax is problematic if your elements contain spaces. That can be
worked around by using a custom separator:
split("aa bb\1cc", dd, "\1")
but then it will fail again if your separator happens to be part of one of the
elements. Many other languages have syntax for array literals, for example C:
char *dd[] = {"aa", "bb", "cc"};
Python:
dd = ['aa', 'bb', 'cc']
JavaScript:
var dd = ['aa', 'bb', 'cc'];
Ruby:
dd = ['aa', 'bb', 'cc']
Go:
dd := []string {"aa", "bb", "cc"}
and so on.
- [bug-gawk] Array literal,
Steven Penny <=