[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
**Subject**: **`math.integer` does not explicitly convert string to integer.**
**From**: Duane Leslie <parakleta@...>
**Date**: Sat, 25 Jun 2016 12:38:06 +1000

I don't know if this is intentional or an oversight, but I have
noticed that without the implicit string to number conversions (i.e.
`LUA_NOCVTS2N`) the `math.tointeger` function will return nil when
passed a string representation of a number. By comparison, the
`tonumber` function will convert strings to numbers explicitly
(obviously since that's exactly what it exists to do).
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?