[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: `math.integer` does not explicitly convert string to integer.
- From: Dirk Laurie <dirk.laurie@...>
- Date: Sat, 25 Jun 2016 14:48:38 +0200
2016-06-25 4:38 GMT+02:00 Duane Leslie <parakleta@darkreality.org>:
> I know I can trivially monkey-patch `math.tointeger` to run its
> arguments through `tonumber` first, but should `math.tointeger` also
> explicitly convert strings to integers where possible?
In general, only arithmetic operators do that, and only concat
converts from number to string. For example, you can't get away
with
n = input_line:match"%d+"
for i=1,n do
...
or with
n = tonumber(input_line)
if #n>8 then
...