lua-users home
lua-l archive

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


The way that `s:find()` works is that `s` has an index to `string`; you can compare `string.find` to `s.find` and find that they *should* be equal (if not, they should implement the exact same functionality at least). When you call `object:method()`, you are doing the equivalent of `object.method(object)`, so `s.find(s, 'there')` is equivalent to `s:find('there')`.

On Fri, Jun 16, 2017 at 2:37 PM John Gabriele <jgabriele@fastmail.fm> wrote:
Hi lua-l,

I understand that:

    > s = 'hello there hi'
    > -- this
    > s:find('there')
    7       11
    > -- is the same as
    > s.find(s, 'there')
    7       11

but what exactly is going on with:

    > -- this
    > s.find(s, 'there')
    7       11
    > -- vs
    > string.find(s, 'there')
    7       11

?

Thanks,
-- John

--
--
Ryan <vandor2012@gmail.com>
Software Developer / System Administrator
https://hashbang.sh