[Top][All Lists]

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

Re: Why string can be added with 0?

From: Wolfgang Laun
Subject: Re: Why string can be added with 0?
Date: Mon, 19 Jul 2021 06:07:44 +0200

See How awk Converts Between Strings and Numbers.
There are languages where the operator defines the kind of operation, and
languages where the type of the argument decides what to do.
If there can be doubts as to the correctness of the data, check.


On Mon, 19 Jul 2021 at 05:36, Peng Yu <> wrote:

> I see this. I don't find anything about it in 6.2.1 Arithmetic Operators.
> $ gawk '{ print typeof($1), $1 + 0 }' <<< a
> string 0
> But it seems that there should be an error to add a string to 0? Is it
> better to show some error instead of assuming a string as 0 in the
> context of arithmetic operations? Thanks.
> --
> Regards,
> Peng

Wolfgang Laun

reply via email to

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