diff options
author | Hanlei Qin <qinhanlei@gmail.com> | 2016-01-20 22:59:48 +0800 |
---|---|---|
committer | Hanlei Qin <qinhanlei@gmail.com> | 2016-01-20 22:59:48 +0800 |
commit | 39825e459f11f8c59d0f39afa6418ad1332ec3a4 (patch) | |
tree | e7b7c03e39001764836120db924fcd64ddbdd3a9 /zh-cn/lua-cn.html.markdown | |
parent | 5477929e8e3c1990c046f245b1e59dbc9df92b45 (diff) |
Update lua-cn.html.markdown
local variables will better.
Diffstat (limited to 'zh-cn/lua-cn.html.markdown')
-rw-r--r-- | zh-cn/lua-cn.html.markdown | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/zh-cn/lua-cn.html.markdown b/zh-cn/lua-cn.html.markdown index 098d0ab5..fc0375f5 100644 --- a/zh-cn/lua-cn.html.markdown +++ b/zh-cn/lua-cn.html.markdown @@ -210,7 +210,7 @@ f2 = {a = 2, b = 3} metafraction = {} function metafraction.__add(f1, f2) - sum = {} + local sum = {} sum.b = f1.b * f2.b sum.a = f1.a * f2.b + f2.a * f1.b return sum @@ -273,7 +273,7 @@ eatenBy = myFavs.animal -- 可以工作!感谢元表 Dog = {} -- 1. function Dog:new() -- 2. - newObj = {sound = 'woof'} -- 3. + local newObj = {sound = 'woof'} -- 3. self.__index = self -- 4. return setmetatable(newObj, self) -- 5. end @@ -307,7 +307,7 @@ mrDog:makeSound() -- 'I say woof' -- 8. LoudDog = Dog:new() -- 1. function LoudDog:makeSound() - s = self.sound .. ' ' -- 2. + local s = self.sound .. ' ' -- 2. print(s .. s .. s) end |