lua-users home
lua-l archive

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


* On 2014-10-31 18:33:07 +0100, Emeka wrote:
 
> mystring = "google+facebook"
> 
> mysringlen = string.len(mystring)
> 
> for i = 1, mystringlen do
>  dosomething(mystring.sub(i,i))
> end
> 
> Is there a better way of doing the above? If yes, please throw it to me :)

More concise would be

mystring:gsub('.', dosomething)

but 'better' might depend on other criteria like perormance. Measure to
be sure.

-- 
:wq
^X^Cy^K^X^C^C^C^C