help-bash
[Top][All Lists]
Advanced

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

[Help-bash] Smart determination of array or associative array based on t


From: Peng Yu
Subject: [Help-bash] Smart determination of array or associative array based on the first key
Date: Mon, 14 Oct 2019 02:04:14 +0800

Bash currently can not use the value of the first key to automatically
determine whether an array or an associative array should be
initialized.

$ x[xxx]=s
$ declare -p x
declare -a x=([0]="s")

In the above example, I'd like `declare -A x` be implicitly called
before `x[xxx]=s` as the key `xxx` is not a number.

I think this feature makes sense because when `xxx` (which is not a
number) is used as the first key, the programmer almost always intends
to use `x` as an associative array instead of an array. Could this
feature be added to bash? Thanks.

-- 
Regards,
Peng



reply via email to

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