lua-users home
lua-l archive

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


On Wed, Sep 10, 2014 at 08:58:34AM -0500, Robert McLay wrote:
> The question I'm asking is why a string literal can be used with string
> member function like format and rep:
> 
>   s = ('5'):rep(10)   --> 5555555555
> 
> I would have normally done:
> 
>     ss = 5
>     s   = ss:rep(10)

rep() is a method for strings. '5' is a string, 5 is a number.  It would
make no sense to execute it on a number.  Indeed, rep() is not a method
on numbers (not via the default metatables, at least.)

B.