lua-users home
lua-l archive

Lua way to do this code

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


Hello,
I'm quite new to lua, but i like simplicity of the language (syntax is too verbose for me, but everything else is great). Firstly, i hope that this is proper place for my small question which isn't too important, but I'm just curious what response i will receive. I've been writing the code, and i got the strange feeling that this snippet isn't written in the way that i should code in lua - or at least functional way.
So i kindly ask: how would you do this iteration?
 local ret = {}
 for p in string.explode(str, ";") do
 local k,v = string.gmatch(p, "([xyz])=(%d+)")()
 ret[k] = tonumber(v)
 end
Thanks,
Mariusz Gliwiński

AltStyle によって変換されたページ (->オリジナル) /