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

Re: for loop 'bad math expression'



On Sun, Feb 4, 2024, at 11:08 AM, Ray Andrews wrote:
> But in my previous post it would seem that 'abc' IS an integer because it increments like one, but even then typeset -p shows it as scalar.

No.  It "increments like one" because you ran "abc=1; let abc+=3",
and the arguments to "let" are interpreted as arithmetic expressions.
If you'd run "abc=1; abc+=3" you would have gotten string concatenation.

> It starts as a string assigned to 'var' but it would seem it gets 'promoted' to an integer variable.

What?  When you ran "abc=1" *you* created that variable.  And it's
not "an integer variable"; it doesn't have the integer attribute.

-- 
vq




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