[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: object method call vs module call?
- From: Ryan <iggyvolz@...>
- Date: Fri, 16 Jun 2017 15:40:58 -0400
Since s is a string, its metatable is the string metatable, so it inherits all methods from string. So s.find is the same method as string.find:
> s='hello there hi'
So you can execute either s.find or string.find and they give the same result. This is most useful when using the object syntax you described, since s:find('there') can be used instead of s.find(s,'there') or string.find(s,'there').