lua-users home
lua-l archive

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


On 19/05/2013, at 5:07 PM, meino.cramer@gmx.de wrote:

>> From my (currently stil a little limited) understanding of lua your
> function will exactly do this...:
> 
> 
>    return str:sub(toleft+1)..str.sub(1,toleft)
>           "shift-part"        "append-aprt"
> 
> ...but when I execute this it seems that only the "shift-part" gets
> executed and the result is 
> 
>     ghijklmnopqstuvxyz

You need to use a colon, not a dot in the second str:sub: str.sub -> str:sub

Lua 5.1.5  Copyright (C) 1994-2012 Lua.org, PUC-Rio
> str = "abcdefghijklmnopqrstuvwxyz"
> toleft = 5
> =str:sub(toleft+1)..str.sub(1,toleft)
fghijklmnopqrstuvwxyz
> return str:sub(toleft+1)..str:sub(1,toleft)
fghijklmnopqrstuvwxyzabcde