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: Alex fxmbsw7 Ratchev
Subject: Re: is there a way to assign indexed arrays like the new assoc arrays way without [..]= typing ?
Date: Sat, 13 Mar 2021 15:45:05 +0100

i know about not using declare by default, im just switching to more using
functions, where i can have 'local' vars for modding \\ working

On Sat, Mar 13, 2021 at 3:33 PM Greg Wooledge <greg@wooledge.org> wrote:

> 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]