[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
@K transformation
From: |
Ilkka Virta |
Subject: |
@K transformation |
Date: |
Thu, 19 Aug 2021 12:15:52 +0300 |
On Thu, Aug 19, 2021 at 5:49 AM Koichi Murase <myoga.murase@gmail.com>
wrote:
> FYI, zsh provides this feature for associative arrays with the syntax
> ${(kv)assoc} or ${(@kv)assoc}. Note that Bash-5.1 already has a
> similar feature ${array[@]@K}, but the substitution result is quoted
> so cannot be directly used for the present purpose.
>
$ declare -A A=([foo bar]="123 456" [adsf]="456 789")
$ printf "<%s>\n" "${A[@]@K}"
<adsf "456 789" "foo bar" "123 456" >
Interesting. I wonder, what's the intended use-case for this?
The impression I have is that it's easier to turn a list of multiple words
into one
string (e.g. for display purposes), but much harder to keep things as
distinct
words (for pretty much anything else). So this seems to have a somewhat
limited
usefulness. I can see "${A[*]@K}" producing a single string like that, but
the same
with [@] seems odd compared to how [@] expansions otherwise work.
- feature request array expansion of keys values pairs and for k v loop, Léa Gris, 2021/08/18
- Re: feature request array expansion of keys values pairs and for k v loop, Koichi Murase, 2021/08/18
- @K transformation,
Ilkka Virta <=
- Re: @K transformation, Koichi Murase, 2021/08/19
- Re: @K transformation, Léa Gris, 2021/08/19
- Re: @K transformation, Koichi Murase, 2021/08/19
- Re: @K transformation, Chet Ramey, 2021/08/20
- Re: @K transformation, Léa Gris, 2021/08/20
- Re: @K transformation, Lawrence Velázquez, 2021/08/20
- Re: @K transformation, Greg Wooledge, 2021/08/20
- Re: @K transformation, Léa Gris, 2021/08/20
- use-cases promote thinking of limited application, L A Walsh, 2021/08/22
- Re: use-cases promote thinking of limited application, Koichi Murase, 2021/08/22