开发者

Lua idioms compiled in one place

开发者 https://www.devze.com 2023-02-06 02:55 出处:网络
I am using Lua for some of my apps. I am looking for a central repository of Lua idioms because I don\'t want to write开发者_如何学Go C in Lua.

I am using Lua for some of my apps. I am looking for a central repository of Lua idioms because I don't want to write开发者_如何学Go C in Lua.

A few examples I've come across are:

x = x or v

This sets a default value for x if it is not already set.

Another is

x, y = y, x

to exchange two variables.


There are a whole bunch of useful snippets and idioms in these links:

http://lua-users.org/wiki/SampleCode

http://www.luafaq.org


Lua Patterns, Tips and Tricks here on Stack Overflow is also very good read.


Try http://lua-users.org/wiki/LuaDirectory - that and the Lua manual/PiL are probably your two best resources in this regard.

  • Lua 5.1 Reference Manual
  • Programming in Lua, 1st Edition (The first edition is available online freely. The second you can buy, though the third edition -- for 5.2 -- should be coming soon.)
0

精彩评论

暂无评论...
验证码 换一张
取 消