lua-users home
lua-l archive

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


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)

I am unable to find this trick discussed in the "Programming in Lua" books or the Lua reference manual.  It clearly works on lua 5.1, 5.2 and luajit 2.0.2.  But is this something that I can assume that it will continue to work?   Is this trick somehow buried in the manuals and I just missed it?  

I found this in some microlight code so I am presuming that it is save to use, but I'd like to know.

Thanks for any light on this subject.
R.