lua-users home
lua-l archive

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


On Thu, Apr 18, 2013 at 4:27 PM, Craig Barnes <craigbarnes85@gmail.com> wrote:
On 18 April 2013 13:15, Chris Datfung <chris.datfung@gmail.com> wrote:
>
> Hi,
>
> I want to pad a string with itself n number of times, for example if n = 3 and var="test" then var = var .. var .. var
>
> I tried with a for loop but get one too many combinations
>
> > a="k"
> > n=3
> > for c = 1, n-1 do a = a..a end
> > print(a)
> kkkk
>
> Is there a smarter way to implement this?
>

print(string.rep("k", 3))


Thanks!