Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: proxy name for array




On 2024-01-10 13:11, Bart Schaefer wrote:
Yes, you could avoid temp with
  set -A "${${(P)1}[pages]}[2]" 50
  set -A "${${(P)1}[pages]}[3]" 100
  set -A "${${(P)1}[pages]}[4]" 150

but that's not as clear or easily maintainable.  You could also do
Agreed.  If I won't have a clue what I was doing in six months then KISS is best.
  temp=${${(P)1}[pages]}  # Note one less (P) and not an array
  set -A "${temp}[2]" 50
  set -A "${temp}[3]" 100
  set -A "${temp}[4]" 150
Once I have this running -- the real function -- I'll try that.
or even

  set -A "${temp}[2,4]" 50 100 150

No, because in the real function there's work to determine what the values will be, they can't be assigned ahead of time.




Messages sorted by: Reverse Date, Date, Thread, Author