help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] Why bash does not recoganize array type smartly?


From: Chet Ramey
Subject: Re: [Help-bash] Why bash does not recoganize array type smartly?
Date: Thu, 10 Mar 2016 10:08:39 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Thunderbird/38.6.0

On 3/9/16 11:16 PM, Peng Yu wrote:
> Hi, Bash requires one explicitly declare associative array before it
> can be used. It seems that this requirement may be too strictly given
> no other types need to be declared first before being used.

The assignment syntax for indexed and associative arrays is identical.
One has to be the default, and it's indexed arrays.

> Is there any rationale why bash is defined in this way. Wouldn't it
> better to allow users define associative array just by using something
> like `x=([a]=1 [b]=2)` without having to declare it?

That is a valid indexed array declaration.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/



reply via email to

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