lua-users home
lua-l archive

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


On Thu, Oct 9, 2008 at 12:32 PM, Jeff Wise <jwise@sealyrealty.com> wrote:
>str = "a"
> num = 97
>=string.find("foobar", str)
>5      5
> =string.find("foobar", num)
>nil

I would expect these results because str = "a" probably makes a 2 byte
field, the "a" and "\0". I would expect "num" not to work because it is
defined as a number (num = 97). Therefore Lua would make it a float long (8
bytes?) value with mantissa and exponent.

In addition, string.find("foobar", num) converts num to a string before searching.

> = string.find("foo97bar", 97)
4       5

Same as doing:

> = string.find("foo97bar", tostring(97))
4       5