help-bash
[Top][All Lists]
Advanced

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

Re: is there a way to assign indexed arrays like the new assoc arrays wa


From: Greg Wooledge
Subject: Re: is there a way to assign indexed arrays like the new assoc arrays way without [..]= typing ?
Date: Sat, 13 Mar 2021 09:33:50 -0500

On Fri, Mar 12, 2021 at 11:11:05PM +0100, Alex fxmbsw7 Ratchev wrote:
> btw i thought i must declare >> -a << the array ? hm :)

Nope.  If you simply assign using array syntax, bash automatically
creates an array.

unset foo
foo=(a b c)
declare -p foo

The only time you must declare anything is when you're creating an
associative array.  And because declaring a variable makes it local
to a function, the -g option was added so that you can create global
associative arrays while inside a function.



reply via email to

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