1
0
mirror of https://github.com/adambard/learnxinyminutes-docs.git synced 2025-08-29 01:21:07 +02:00

korean version of javascript and lua tutorials added

This commit is contained in:
wikibook
2013-08-13 15:42:33 +09:00
parent bd48b7062c
commit 04c0b273b0
2 changed files with 858 additions and 0 deletions

423
ko-kr/lua-kr.html.markdown Normal file
View File

@@ -0,0 +1,423 @@
---
language: lua
category: language
contributors:
- ["Tyler Neylon", "http://tylerneylon.com/"]
translators:
- ["wikibook", "http://wikibook.co.kr"]
lang: ko-kr
---
```lua
-- <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD> <20><> <20><>¥<EFBFBD><C2A5> <20>ּ<EFBFBD><D6BC><EFBFBD> <20>ǹ<EFBFBD><C7B9>մϴ<D5B4>.
--[[
[<5B><> ]<5D><> <20><> <20><><EFBFBD><EFBFBD> <20>߰<EFBFBD><DFB0>ϸ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><> <20>ּ<EFBFBD><D6BC><EFBFBD> <20>˴ϴ<CBB4>.
--]]
----------------------------------------------------
-- 1. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><20><><EFBFBD><EFBFBD>
----------------------------------------------------
num = 42 -- <20><><EFBFBD><EFBFBD> <20><><EFBFBD>ڴ<EFBFBD> double<6C>Դϴ<D4B4>.
-- <20><><EFBFBD><EFBFBD> <20>ʿ<EFBFBD><CABF><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD>. 64<36><34>Ʈ double<6C><65>
-- <20><>Ȯ<EFBFBD><C8AE> int <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϱ<EFBFBD> <20><><EFBFBD><EFBFBD> 52<35><32>Ʈ<EFBFBD><C6AE> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
-- <20>ֽ<EFBFBD><D6BD>ϴ<EFBFBD>. 52<35><32>Ʈ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> int <20><><EFBFBD><EFBFBD> <20><><EFBFBD>ؼ<EFBFBD><D8BC><EFBFBD>
-- <20><><EFBFBD><EFBFBD> <20><><EFBFBD>е<EFBFBD><D0B5><EFBFBD> <20><><EFBFBD>õ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ʽ<EFBFBD><CABD>ϴ<EFBFBD>.
s = 'walternate' -- <20><><EFBFBD>̽<EFBFBD><CCBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>Һ<EFBFBD> <20><><EFBFBD>ڿ<EFBFBD>
t = <><C5AB><EFBFBD><EFBFBD>ǥ<EFBFBD><C7A5> <20><20>˴ϴ<CBB4>"
u = [[ <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>ȣ<EFBFBD><C8A3>
<20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD>ڿ<EFBFBD><DABF><EFBFBD>
<20><>Ÿ<EFBFBD><C5B8><EFBFBD>ϴ<EFBFBD>.]]
t = nil -- <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> t. <20><><EFBFBD>ƴ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>÷<EFBFBD><C3B7><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>մϴ<D5B4>.
-- <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> do/end<6E><64> <20><><EFBFBD><EFBFBD> Ű<><C5B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>Ÿ<EFBFBD><C5B8><EFBFBD>ϴ<EFBFBD>:
while num < 50 do
num = num + 1 -- ++<2B><> += <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD> <20><> <20><> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD>.
end
-- If <20><>:
if num > 40 then
print('40 <20>̻<EFBFBD>')
elseif s ~= 'walternate' then -- ~=<3D><> '<27><><EFBFBD><EFBFBD> <20>ʴ<EFBFBD>'<27>Դϴ<D4B4>.
-- <20><><EFBFBD>ϼ<EFBFBD> <20>˻<EFBFBD><CBBB><EFBFBD> <20><><EFBFBD>̽<EFBFBD><CCBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ==<3D>Դϴ<D4B4>.
-- <20><><EFBFBD>ڿ<EFBFBD><DABF><EFBFBD><EFBFBD><EFBFBD> <20><> <20><> <20>ֽ<EFBFBD><D6BD>ϴ<EFBFBD>.
io.write('not over 40\n') -- <20><EFBFBD><E2BABB><EFBFBD><EFBFBD><EFBFBD><EFBFBD> stdout<75><74> <20><><EFBFBD>ϴ<EFBFBD>.
else
-- <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><EFBFBD><E2BABB><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Դϴ<D4B4>.
thisIsGlobal = 5 -- <20><>Ÿ ǥ<><C7A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>Ϲ<EFBFBD><CFB9><EFBFBD><EFBFBD>Դϴ<D4B4>.
-- <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD>:
local line = io.read() -- <20><><EFBFBD><EFBFBD> stdin <20><><EFBFBD><EFBFBD> <20>н<EFBFBD><D0BD>ϴ<EFBFBD>
-- <20><><EFBFBD>ڿ<EFBFBD> <20><><EFBFBD><EFBFBD><E1BFA1> .. <20><><EFBFBD><EFBFBD><EFBFBD>ڸ<EFBFBD> <20><><EFBFBD>ϴ<EFBFBD>:
print('<27>ܿ<EFBFBD><DCBF><EFBFBD> <20><><EFBFBD><EFBFBD> <20>ֽ<EFBFBD><D6BD>ϴ<EFBFBD>, ' .. line)
end
-- <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> nil<69><6C> <20><>ȯ<EFBFBD>մϴ<D5B4>.
-- <20><><EFBFBD><EFBFBD> <20>ڵ带 <20><><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>ʽ<EFBFBD><CABD>ϴ<EFBFBD>:
foo = anUnknownVariable -- <20><><EFBFBD><EFBFBD> foo<6F><6F> nil<69>Դϴ<D4B4>.
aBoolValue = false
-- nil<69><6C> false<73><65><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դϴ<D4B4>; 0<><30> ''<27><> <20><><EFBFBD>Դϴ<D4B4>!
if not aBoolValue then print('twas false') end
-- 'or'<27><> 'and'<27><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>(short-circuit)<29>˴ϴ<CBB4>.
-- <20><><EFBFBD><EFBFBD> <20>ڵ<EFBFBD><DAB5><EFBFBD> C/<2F>ڹٽ<DAB9>ũ<EFBFBD><C5A9>Ʈ<EFBFBD><C6AE> a?b:c <20><><EFBFBD><EFBFBD><EFBFBD>ڿ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>մϴ<D5B4>:
ans = aBoolValue and 'yes' or 'no' --> 'no'
karlSum = 0
for i = 1, 100 do -- <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>ҵ<EFBFBD> <20><><EFBFBD>Ե˴ϴ<CBB4>.
karlSum = karlSum + i
end
-- ī<><C4AB>Ʈ <20>ٿ<EFBFBD><D9BF><EFBFBD> <20><> <20><><EFBFBD><EFBFBD> "100, 1, -1"<22><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>ϴ<EFBFBD>.
fredSum = 0
for j = 100, 1, -1 do fredSum = fredSum + j end
-- <20>Ϲ<EFBFBD><CFB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> begin, end[, step]<5D>Դϴ<D4B4>.
-- <20><> <20>ٸ<EFBFBD> <20>ݺ<EFBFBD><DDBA><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD>:
repeat
print('<27>̷<EFBFBD><CCB7><EFBFBD> <20><><EFBFBD><EFBFBD>')
num = num - 1
until num == 0
----------------------------------------------------
-- 2. <20>Լ<EFBFBD>
----------------------------------------------------
function fib(n)
if n < 2 then return n end
return fib(n - 2) + fib(n - 1)
end
-- Ŭ<><C5AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>͸<EFBFBD> <20>Լ<EFBFBD><D4BC><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20>ֽ<EFBFBD><D6BD>ϴ<EFBFBD>:
function adder(x)
-- <20><>ȯ<EFBFBD><C8AF> <20>Լ<EFBFBD><D4BC><EFBFBD> adder<65><72> ȣ<><C8A3><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD> x<><78>
-- <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>˴ϴ<CBB4>:
return function (y) return x + y end
end
a1 = adder(9)
a2 = adder(36)
print(a1(16)) --> 25
print(a2(64)) --> 100
-- <20><>ȯ<EFBFBD><C8AF>, <20>Լ<EFBFBD> ȣ<><C8A3>, <20>Ҵ繮<D2B4><E7B9AE> <20><><EFBFBD>̰<EFBFBD> <20>ٸ<EFBFBD>
-- <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>Ʈ<EFBFBD><C6AE> <20><><EFBFBD>ؼ<EFBFBD><D8BC><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>մϴ<D5B4>.
-- <20><><EFBFBD><EFBFBD>Ʈ<EFBFBD><C6AE> <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> nil<69><6C> <20>Ҵ<EFBFBD>/<2F><>ȯ<EFBFBD>ǰ<EFBFBD>
-- <20><><EFBFBD><EFBFBD>Ʈ<EFBFBD><C6AE> <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD>.
x, y, z = 1, 2, 3, 4
-- <20><><EFBFBD><EFBFBD> x = 1, y = 2, z = 3<>̰<EFBFBD> 4<><34> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD>.
function bar(a, b, c)
print(a, b, c)
return 4, 8, 15, 16, 23, 42
end
x, y = bar('zaphod') --> "zaphod nil nil"<22><> <20><><EFBFBD><EFBFBD>
-- <20><><EFBFBD><EFBFBD> x = 4, y = 8<>̰<EFBFBD> 15~42<34><32> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD>.
-- <20>Լ<EFBFBD><D4BC><EFBFBD> <20>ϱ<EFBFBD> <20><>ü<EFBFBD>̰<EFBFBD>, <20><><EFBFBD><EFBFBD>/<2F><><EFBFBD><EFBFBD> <20><>ȿ<EFBFBD><C8BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
-- <20><> <20>ֽ<EFBFBD><D6BD>ϴ<EFBFBD>. <20>Ʒ<EFBFBD><C6B7><EFBFBD> <20><> <20>Լ<EFBFBD><D4BC><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD>:
function f(x) return x * x end
f = function (x) return x * x end
-- <20>׸<EFBFBD><D7B8><EFBFBD> <20>Ʒ<EFBFBD><C6B7><EFBFBD> <20><> <20>Լ<EFBFBD><D4BC><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դϴ<D4B4>:
local function g(x) return math.sin(x) end
local g; g = function (x) return math.sin(x) end
-- 'local g'<27><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϸ<EFBFBD> g<><67> <20><><EFBFBD><EFBFBD> <20>Լ<EFBFBD><D4BC><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD>.
-- <20>׳<EFBFBD><D7B3><EFBFBD><EFBFBD><EFBFBD> <20><20>Լ<EFBFBD><D4BC><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>մϴ<D5B4>.
-- <20>Լ<EFBFBD><D4BC><EFBFBD> ȣ<><C8A3><EFBFBD><EFBFBD> <20><> <20><><EFBFBD>ڿ<EFBFBD> <20>Ű<EFBFBD><C5B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ϳ<EFBFBD><CFB3><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ѵٸ<D1B4>
-- <20><>ȣ<EFBFBD><C8A3> <20><><EFBFBD><EFBFBD> <20>ʾƵ<CABE> <20>˴ϴ<CBB4>:
print 'hello' -- <20><> <20><><EFBFBD><EFBFBD><EFBFBD>մϴ<D5B4>.
----------------------------------------------------
-- 3. <20><><EFBFBD>̺<EFBFBD>
----------------------------------------------------
-- <20><><EFBFBD>̺<EFBFBD> = <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>ڷᱸ<DAB7><E1B1B8><EFBFBD>μ<EFBFBD>, <20><><EFBFBD><EFBFBD> <20><EFBFBD>Դϴ<D4B4>.
-- PHP<48><50> <20><EFBFBD>̳<EFBFBD> <20>ڹٽ<DAB9>ũ<EFBFBD><C5A9>Ʈ<EFBFBD><C6AE> <20><>ü<EFBFBD><C3BC> <20><><EFBFBD><EFBFBD><EFBFBD>ϸ<EFBFBD>,
-- <20><><EFBFBD><EFBFBD>Ʈ<EFBFBD>ε<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20>ִ<EFBFBD> <20>ؽ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>ųʸ<C5B3><CAB8>Դϴ<D4B4>.
-- <20><><EFBFBD>̺<EFBFBD><CCBA><EFBFBD> <20><><EFBFBD>ųʸ<C5B3>/<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϱ<EFBFBD>:
-- <20><><EFBFBD>ųʸ<C5B3> <20><><EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD> <20><EFBFBD><E2BABB><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>ڿ<EFBFBD> Ű<><C5B0> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD>:
t = {key1 = 'value1', key2 = false}
-- <20><><EFBFBD>ڿ<EFBFBD> Ű<><C5B0><EFBFBD><EFBFBD> <20>ڹٽ<DAB9>ũ<EFBFBD><C5A9>Ʈ<EFBFBD><C6AE> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> ǥ<><C7A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><> <20>ֽ<EFBFBD><D6BD>ϴ<EFBFBD>:
print(t.key1) -- 'value1'<27><> <20><><EFBFBD><EFBFBD>.
t.newKey = {} -- <20><> Ű/<2F><> <20><><EFBFBD><EFBFBD> <20>߰<EFBFBD>.
t.key2 = nil -- <20><><EFBFBD>̺<EFBFBD><CCBA><EFBFBD><EFBFBD><EFBFBD> key2<79><32> <20><><EFBFBD><EFBFBD>.
-- (nil<69><6C> <20>ƴ<EFBFBD>) <20><><EFBFBD><EFBFBD> Ű<><C5B0> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD> <20><><EFBFBD>ͷ<EFBFBD> ǥ<><C7A5><EFBFBD><EFBFBD>:
u = {['@!#'] = 'qbert', [{}] = 1729, [6.28] = 'tau'}
print(u[6.28]) -- "tau"<22><> <20><><EFBFBD><EFBFBD>
-- Ű <20><>Ī<EFBFBD><C4AA> <20><EFBFBD><E2BABB><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>ڿ<EFBFBD> <20><><EFBFBD>ڿ<EFBFBD><DABF><EFBFBD> <20><><EFBFBD>ؼ<EFBFBD><D8BC><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
-- <20><><EFBFBD>̺<EFBFBD><CCBA><EFBFBD> <20><><EFBFBD>ؼ<EFBFBD><D8BC><EFBFBD> <20>ĺ<EFBFBD><C4BA>ڷ<EFBFBD> <20>մϴ<D5B4>.
a = u['@!#'] -- Now a = 'qbert'.
b = u[{}] -- We might expect 1729, but it's nil:
a = u['@!#'] -- <20><><EFBFBD><EFBFBD> a<><61> 'qbert'<27>Դϴ<D4B4>.
b = u[{}] -- 1729<32><39> <20><><EFBFBD><EFBFBD><EFBFBD>߰<EFBFBD><DFB0><EFBFBD><EFBFBD><EFBFBD> nil<69>Դϴ<D4B4>:
-- Ž<><C5BD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϱ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> b<><62> nil<69>Դϴ<D4B4>. Ž<><C5BD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
-- <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Ű<><C5B0> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Ű<><C5B0> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ü<EFBFBD><C3BC> <20>ƴϱ<C6B4>
-- <20><><EFBFBD><EFBFBD><EFBFBD>Դϴ<D4B4>. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>ڿ<EFBFBD> <20><> <20><><EFBFBD>ڰ<EFBFBD> <20><> <20><> <20>̽ļ<CCBD> <20>ִ<EFBFBD> Ű<>Դϴ<D4B4>.
-- <20><><EFBFBD>̺<EFBFBD> <20>ϳ<EFBFBD><CFB3><EFBFBD> <20>Ű<EFBFBD><C5B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>ϴ<EFBFBD> <20>Լ<EFBFBD><D4BC><EFBFBD> ȣ<><C8A3><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><>ȣ<EFBFBD><C8A3> <20>ʿ<EFBFBD><CABF><EFBFBD><EFBFBD><EFBFBD> <20>ʽ<EFBFBD><CABD>ϴ<EFBFBD>:
function h(x) print(x.key1) end
h{key1 = 'Sonmi~451'} -- 'Sonmi~451'<27><> <20><><EFBFBD><EFBFBD>.
for key, val in pairs(u) do -- <20><><EFBFBD>̺<EFBFBD> <20><>ȸ
print(key, val)
end
-- _G<5F><47> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> Ư<><C6AF><EFBFBD><EFBFBD> <20><><EFBFBD>̺<EFBFBD><CCBA>Դϴ<D4B4>.
print(_G['_G'] == _G) -- 'true'<27><> <20><><EFBFBD><EFBFBD>
-- <20><><EFBFBD>̺<EFBFBD><CCBA><EFBFBD> <20><><EFBFBD><EFBFBD>Ʈ/<2F><EFBFBD><E8BFAD> <20><><EFBFBD><EFBFBD><EFBFBD>ϱ<EFBFBD>:
-- <20><><EFBFBD><EFBFBD>Ʈ <20><><EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD> <20>Ϲ<EFBFBD><CFB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> int Ű<><C5B0> <20><><EFBFBD><EFBFBD><EFBFBD>˴ϴ<CBB4>:
v = {'value1', 'value2', 1.21, 'gigawatts'}
for i = 1, #v do -- #v<><76> <20><><EFBFBD><EFBFBD>Ʈ v<><76> ũ<><C5A9><EFBFBD>Դϴ<D4B4>.
print(v[i]) -- <20>ε<EFBFBD><CEB5><EFBFBD><EFBFBD><EFBFBD> 1<><31><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>մϴ<D5B4>!! <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ƴմϴ<D5B4>!
end
-- 'list'<27><> <20><><EFBFBD><EFBFBD> Ÿ<><C5B8><EFBFBD><EFBFBD> <20>ƴմϴ<D5B4>. v<><76> <20><><EFBFBD>ӵ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Ű<><C5B0> <20><><EFBFBD>Ե<EFBFBD>
-- <20><><EFBFBD>̺<EFBFBD><CCBA>̰<EFBFBD> <20><><EFBFBD><EFBFBD>Ʈ<EFBFBD><C6AE> <20><><EFBFBD>޵<EFBFBD> <20><><EFBFBD>Դϴ<D4B4>.
----------------------------------------------------
-- 3.1 <20><>Ÿ<EFBFBD><C5B8><EFBFBD>̺<EFBFBD><CCBA><EFBFBD> <20><>Ÿ<EFBFBD>޼<EFBFBD><DEBC><EFBFBD>
----------------------------------------------------
-- <20><><EFBFBD>̺<EFBFBD><CCBA><EFBFBD> <20><><EFBFBD>̺<EFBFBD><CCBA><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ε<EFBFBD><CEB5><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϰ<EFBFBD> <20>ϴ<EFBFBD> <20><>Ÿ<EFBFBD><C5B8><EFBFBD>̺<EFBFBD><CCBA><EFBFBD>
-- <20><><EFBFBD><EFBFBD> <20><> <20>ֽ<EFBFBD><D6BD>ϴ<EFBFBD>. <20><><EFBFBD>߿<EFBFBD> <20><>Ÿ<EFBFBD><C5B8><EFBFBD>̺<EFBFBD><CCBA><EFBFBD> <20><EFBFBD><EEB6BB> <20>ڹٽ<DAB9>ũ<EFBFBD><C5A9>Ʈ
-- <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ÿ<EFBFBD>԰<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD><CFB4><EFBFBD> <20><><EFBFBD><EFBFBD>ڽ<EFBFBD><DABD>ϴ<EFBFBD>.
f1 = {a = 1, b = 2} -- <20>м<EFBFBD> a/b<><62> ǥ<><C7A5>
f2 = {a = 2, b = 3}
-- <20><><EFBFBD><EFBFBD> <20>ڵ<EFBFBD><DAB5><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>մϴ<D5B4>:
-- s = f1 + f2
metafraction = {}
function metafraction.__add(f1, f2)
sum = {}
sum.b = f1.b * f2.b
sum.a = f1.a * f2.b + f2.a * f1.b
return sum
end
setmetatable(f1, metafraction)
setmetatable(f2, metafraction)
s = f1 + f2 -- f1<66><31> <20><>Ÿ<EFBFBD><C5B8><EFBFBD>̺<EFBFBD><CCBA><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> __add(f1, f2)<29><> ȣ<><C8A3>
-- f1<66><31> f2<66><32> <20>ڹٽ<DAB9>ũ<EFBFBD><C5A9>Ʈ<EFBFBD><C6AE> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ÿ<EFBFBD>԰<EFBFBD> <20>޸<EFBFBD> <20><> <20><>Ÿ<EFBFBD><C5B8><EFBFBD>̺<EFBFBD><CCBA><EFBFBD> <20><><EFBFBD><EFBFBD>
-- Ű<><C5B0> <20><><EFBFBD> getmetatable(f1)<29><> <20><><EFBFBD><EFBFBD> <20>޾ƿ;<C6BF> <20>մϴ<D5B4>.
-- <20><>Ÿ<EFBFBD><C5B8><EFBFBD>̺<EFBFBD><CCBA><EFBFBD> __add <20><><EFBFBD><EFBFBD> <20><><EFBFBD>ư<EFBFBD> <20>˰<EFBFBD> <20>ִ<EFBFBD> Ű<><C5B0> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>Ϲ<EFBFBD> <20><><EFBFBD>̺<EFBFBD><CCBA>Դϴ<D4B4>.
-- <20>׷<EFBFBD><D7B7><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> s<><73> <20><>Ÿ<EFBFBD><C5B8><EFBFBD>̺<EFBFBD><CCBA><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>ʱ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>մϴ<D5B4>.
-- t = s + s
-- <20>Ʒ<EFBFBD><C6B7><EFBFBD> <20><><EFBFBD><EFBFBD> Ŭ<><C5AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>̷<EFBFBD><CCB7><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>߻<EFBFBD><DFBB><EFBFBD><EFBFBD><EFBFBD> <20>ʽ<EFBFBD><CABD>ϴ<EFBFBD>.
-- <20><>Ÿ<EFBFBD><C5B8><EFBFBD>̺<EFBFBD><CCBA><EFBFBD> <20><><EFBFBD><EFBFBD> __index<65><78> <20><><EFBFBD><EFBFBD> <20>̿<EFBFBD><CCBF><EFBFBD> Ž<><C5BD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ε<EFBFBD><CEB5>մϴ<D5B4>:
defaultFavs = {animal = 'gru', food = 'donuts'}
myFavs = {food = 'pizza'}
setmetatable(myFavs, {__index = defaultFavs})
eatenBy = myFavs.animal -- <20><><EFBFBD><EFBFBD><EFBFBD>մϴ<D5B4>! <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><>Ÿ<EFBFBD><C5B8><EFBFBD>̺<EFBFBD>!
-- <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>Ÿ<EFBFBD><C5B8><EFBFBD>̺<EFBFBD> Ž<><C5BD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><>Ÿ<EFBFBD><C5B8><EFBFBD>̺<EFBFBD><CCBA><EFBFBD> __index <20><><EFBFBD><EFBFBD> <20>̿<EFBFBD><CCBF><EFBFBD>
-- <20><><EFBFBD>õ<EFBFBD><C3B5>ϰ<EFBFBD>, <20>̷<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ݺ<EFBFBD><DDBA>˴ϴ<CBB4>.
-- __index <20><><EFBFBD><EFBFBD> <20><> <20><> <20><><EFBFBD><EFBFBD>ȭ<EFBFBD><C8AD> Ž<><C5BD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> function(tbl, key)<29><>
-- <20><> <20><><EFBFBD><EFBFBD> <20>ֽ<EFBFBD><D6BD>ϴ<EFBFBD>.
-- __index, __add, ...<2E><> <20><><EFBFBD><EFBFBD> <20><>Ÿ<EFBFBD>޼<EFBFBD><DEBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>մϴ<D5B4>.
-- <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>Ÿ<EFBFBD>޼<EFBFBD><DEBC><20><><EFBFBD><EFBFBD> <20><><EFBFBD>̺<EFBFBD><CCBA><EFBFBD> <20><>ü <20><><EFBFBD><EFBFBD><EFBFBD>Դϴ<D4B4>.
-- __add(a, b) for a + b
-- __sub(a, b) for a - b
-- __mul(a, b) for a * b
-- __div(a, b) for a / b
-- __mod(a, b) for a % b
-- __pow(a, b) for a ^ b
-- __unm(a) for -a
-- __concat(a, b) for a .. b
-- __len(a) for #a
-- __eq(a, b) for a == b
-- __lt(a, b) for a < b
-- __le(a, b) for a <= b
-- __index(a, b) <fn<66>̳<EFBFBD> <20><><EFBFBD>̺<EFBFBD>> for a.b
-- __newindex(a, b, c) for a.b = c
-- __call(a, ...) for a(...)
----------------------------------------------------
-- 3.2 Ŭ<><C5AC><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>̺<EFBFBD><CCBA><EFBFBD> <20><><EFBFBD><EFBFBD>
----------------------------------------------------
-- <20><><EFBFBD>ƿ<EFBFBD><C6BF><EFBFBD> Ŭ<><C5AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD>̺<EFBFBD><CCBA><EFBFBD> <20><>Ÿ<EFBFBD><C5B8><EFBFBD>̺<EFBFBD><CCBA><EFBFBD>
-- <20>̿<EFBFBD><CCBF><EFBFBD> Ŭ<><C5AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>پ<EFBFBD><D9BE><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ֽ<EFBFBD><D6BD>ϴ<EFBFBD>.
-- <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ϴ<EFBFBD><CFB4><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>մϴ<D5B4>.
Dog = {} -- 1.
function Dog:new() -- 2.
newObj = {sound = 'woof'} -- 3.
self.__index = self -- 4.
return setmetatable(newObj, self) -- 5.
end
function Dog:makeSound() -- 6.
print('I say ' .. self.sound)
end
mrDog = Dog:new() -- 7.
mrDog:makeSound() -- 'I say woof' -- 8.
-- 1. Dog<6F><67> Ŭ<><C5AC><EFBFBD><EFBFBD>ó<EFBFBD><C3B3> <20><><EFBFBD><EFBFBD><EFBFBD>մϴ<D5B4>. <20><><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD> <20><><EFBFBD>̺<EFBFBD><CCBA>Դϴ<D4B4>.
-- 2. function <20><><EFBFBD>̺<EFBFBD><CCBA><EFBFBD>:fn(...)<29><>
-- function <20><><EFBFBD>̺<EFBFBD><CCBA><EFBFBD>.fn(self, ...)<29><> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD>.
-- :<3A><> self<6C><66><EFBFBD><EFBFBD> ù <20><>° <20><><EFBFBD>ڸ<EFBFBD> <20>߰<EFBFBD><DFB0><EFBFBD> <20><><EFBFBD>Դϴ<D4B4>.
-- self<6C><66> <20><><EFBFBD><EFBFBD> <20><EFBFBD><EEB6BB> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ñ<EFBFBD><C3B1>ϴٸ<CFB4> <20>Ʒ<EFBFBD><C6B7><EFBFBD> 7<><37> 8<><38> <20>о<D0BE><EEBAB8><EFBFBD><EFBFBD>.
-- 3. newObj<62><6A> Dog Ŭ<><C5AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ν<EFBFBD><CEBD>Ͻ<EFBFBD><CFBD><EFBFBD> <20>˴ϴ<CBB4>.
-- 4. self = <20>ν<EFBFBD><CEBD>Ͻ<EFBFBD>ȭ<EFBFBD>Ǵ<EFBFBD> Ŭ<><C5AC><EFBFBD><EFBFBD>.
-- <20>ַ<EFBFBD> self = Dog<6F><67><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>̿<EFBFBD><CCBF>ϸ<EFBFBD> <20>̰<EFBFBD><CCB0><EFBFBD> <20>ٲ<EFBFBD> <20><> <20>ֽ<EFBFBD><D6BD>ϴ<EFBFBD>.
-- newObj<62><6A> <20><>Ÿ<EFBFBD><C5B8><EFBFBD>̺<EFBFBD><CCBA><EFBFBD> self<6C><66> __index<65><78> <20><><EFBFBD><EFBFBD> self<6C><66> <20><><EFBFBD><EFBFBD><EFBFBD>ϸ<EFBFBD>
-- newObj<62><6A> self<6C><66> <20>Լ<EFBFBD><D4BC><EFBFBD> <20><><EFBFBD><EFBFBD> <20>˴ϴ<CBB4>.
-- 5. <20><><EFBFBD><EFBFBD>: setmetatable<6C><65> ù <20><>° <20><><EFBFBD>ڸ<EFBFBD> <20><>ȯ<EFBFBD>մϴ<D5B4>.
-- 6. :<3A><> 2<><32><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>Ͱ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>̹<EFBFBD><CCB9><EFBFBD><EFBFBD><EFBFBD> self<6C><66>
-- Ŭ<><C5AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ƴ<EFBFBD> <20>ν<EFBFBD><CEBD>Ͻ<EFBFBD><CFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20>ֽ<EFBFBD><D6BD>ϴ<EFBFBD>.
-- 7. Dog.new(Dog)<29><> <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD> new()<29><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> self = Dog<6F>Դϴ<D4B4>.
-- 8. mrDog.makeSound(mrDog)<29><> <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD> self = mrDog<6F>Դϴ<D4B4>.
----------------------------------------------------
-- <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>:
LoudDog = Dog:new() -- 1.
function LoudDog:makeSound()
s = self.sound .. ' ' -- 2.
print(s .. s .. s)
end
seymour = LoudDog:new() -- 3.
seymour:makeSound() -- 'woof woof woof' -- 4.
-- 1. LoudDog<6F><67> Dog<6F><67> <20>޼<EFBFBD><DEBC><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>˴ϴ<CBB4>.
-- 2. self<6C><66> new()<29><><EFBFBD><EFBFBD> 'sound' Ű<><C5B0> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD>. 3<><33> <20><><EFBFBD><EFBFBD><EFBFBD>ϼ<EFBFBD><CFBC><EFBFBD>.
-- 3. LoudDog.new(LoudDog)<29><> <20><><EFBFBD><EFBFBD>, LoudDog<6F><67> 'new' Ű<><C5B0> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
-- <20><>Ÿ<EFBFBD><C5B8><EFBFBD>̺<EFBFBD><CCBA><EFBFBD><EFBFBD><EFBFBD> __index = Dog<6F>̱<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Dog.new(LoudDog)<29><><EFBFBD><EFBFBD>
-- <20><>ȯ<EFBFBD>˴ϴ<CBB4>.
-- <20><><EFBFBD><EFBFBD>: seymour<75><72> <20><>Ÿ<EFBFBD><C5B8><EFBFBD>̺<EFBFBD><CCBA><EFBFBD> LoudDog<6F>̰<EFBFBD> LoudDog.__index<65><78>
-- LoudDog<6F>Դϴ<D4B4>. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> seymour.key<65><79> seymour.key,
-- LoudDog.key, Dog.key<65><79> <20><><EFBFBD><EFBFBD> <20><><EFBFBD≯<EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Ű<><C5B0> <20><20><><EFBFBD>̺<EFBFBD><CCBA><EFBFBD>
-- <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>Դϴ<D4B4>.
-- 4. 'makeSound' Ű<><C5B0> LoudDog<6F><67><EFBFBD><EFBFBD> <20>߰<EFBFBD><DFB0><EFBFBD> <20><> <20>ֽ<EFBFBD><D6BD>ϴ<EFBFBD>.
-- <20>̰<EFBFBD><CCB0><EFBFBD> LoudDog.makeSound(seymour)<29><> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD>.
-- <20>ʿ<EFBFBD><CABF><EFBFBD> <20><><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD> Ŭ<><C5AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD> new()<29><> <20><><EFBFBD><EFBFBD> Ŭ<><C5AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD> new()<29><> <20><><EFBFBD><EFBFBD><EFBFBD>մϴ<D5B4>.
function LoudDog:new()
newObj = {}
-- set up newObj
self.__index = self
return setmetatable(newObj, self)
end
----------------------------------------------------
-- 4. <20><><EFBFBD><EFBFBD>
----------------------------------------------------
--[[ <20><><EFBFBD><20>ּ<EFBFBD><D6BC><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϸ<EFBFBD> <20><> <20><>ũ<EFBFBD><C5A9>Ʈ<EFBFBD><C6AE> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>κ<EFBFBD><CEBA><EFBFBD>
-- <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>°<EFBFBD> <20>˴ϴ<CBB4>.
```
```lua
-- mod.lua <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>ٰ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>ô<EFBFBD>.
local M = {}
local function sayMyName()
print('<27>̼ҷ<CCBC>')
end
function M.sayHello()
print('<27>ȳ<EFBFBD><C8B3>ϼ<EFBFBD><CFBC><EFBFBD>')
sayMyName()
end
return M
-- <20><> <20>ٸ<EFBFBD> <20><><EFBFBD>Ͽ<EFBFBD><CFBF><EFBFBD><EFBFBD><EFBFBD> mod.lua<75><61> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>̿<EFBFBD><CCBF><EFBFBD> <20><> <20>ֽ<EFBFBD><D6BD>ϴ<EFBFBD>.
local mod = require('mod') -- mod.lua <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
-- require<72><65> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>Խ<EFBFBD>Ű<EFBFBD><C5B0> ǥ<><C7A5>ȭ<EFBFBD><C8AD> <20><><EFBFBD><EFBFBD><EFBFBD>Դϴ<D4B4>.
-- require<72><65> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>մϴ<D5B4>: (ij<>̵<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>. <20>ϴ<EFBFBD> <20><><EFBFBD><EFBFBD>)
local mod = (function ()
<mod.lua<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>>
end)()
-- mod.lua<75><61> <20>Լ<EFBFBD><D4BC><EFBFBD> <20><><EFBFBD><EFBFBD>ó<EFBFBD><C3B3> <20>ǹǷ<C7B9> mod.lua <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
-- <20>ۿ<EFBFBD><DBBF><EFBFBD> <20><> <20><> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD>.
-- <20><><EFBFBD><EFBFBD> <20>ڵ尡 <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD> <20><><EFBFBD><EFBFBD> mod<6F><64> mod.lua<75><61> M<><4D> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Դϴ<D4B4>.
mod.sayHello() -- <20>̼ҷ<CCBC> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>λ縦 <20>dzܴϴ<DCB4>.
-- <20><><EFBFBD><EFBFBD> <20>ڵ带 <20><><EFBFBD><EFBFBD><EFBFBD>ϸ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>߻<EFBFBD><DFBB>մϴ<D5B4>.
-- sayMyName<6D><65> mod.lua <20>ȿ<EFBFBD><C8BF><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϱ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Դϴ<D4B4>:
mod.sayMyName() -- <20><><EFBFBD><EFBFBD>
-- require<72><65> <20><>ȯ<EFBFBD><C8AF><EFBFBD><EFBFBD> ij<>̵ǹǷ<C7B9> require<72><65> <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD>
-- <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ִ<EFBFBD> <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>˴ϴ<CBB4>.
-- mod2.lua<75><61> "print('Hi')"<22><> <20><><EFBFBD><EFBFBD> <20>ִٰ<D6B4> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>ô<EFBFBD>.
local a = require('mod2') -- Hi!<21><> <20><><EFBFBD><EFBFBD>
local b = require('mod2') -- print<6E><74> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>. a=b
-- dofile<6C><65> require<72><65> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ij<><C4B3><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>ʽ<EFBFBD><CABD>ϴ<EFBFBD>:
dofile('mod2') --> Hi!
dofile('mod2') --> Hi! (require<72><65> <20>޸<EFBFBD> <20>ٽ<EFBFBD> <20>ѹ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
-- loadfile<6C><65> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>о<EFBFBD><D0BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ʽ<EFBFBD><CABD>ϴ<EFBFBD>
f = loadfile('mod2') -- f()<29><> ȣ<><C8A3><EFBFBD>ؾ<EFBFBD> mod2.lua<75><61> <20><><EFBFBD><EFBFBD><EFBFBD>˴ϴ<CBB4>.
-- loadstring<6E><67> <20><><EFBFBD>ڿ<EFBFBD><DABF><EFBFBD> <20><><EFBFBD><EFBFBD> loadfile<6C>Դϴ<D4B4>.
g = loadstring('print(343)') -- <20>Լ<EFBFBD><D4BC><EFBFBD> <20><>ȯ<EFBFBD>մϴ<D5B4>.
g() -- 343<34><33> <20><><EFBFBD>µ˴ϴ<CBB4>. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ƹ<EFBFBD><C6B9>͵<EFBFBD> <20><><EFBFBD>µ<EFBFBD><C2B5><EFBFBD> <20>ʽ<EFBFBD><CABD>ϴ<EFBFBD>.
--]]
```
## <20><><EFBFBD><EFBFBD><EFBFBD>ڷ<EFBFBD>
<EFBFBD><EFBFBD><EFBFBD>Ƹ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ߴ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <a href="http://love2d.org/">Love 2D <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD></a><EFBFBD><EFBFBD> <20>̿<EFBFBD><CCBF><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><> <20>־<EFBFBD><D6BE><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Դϴ<D4B4>. <20>̰<EFBFBD><CCB0><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD>Ƹ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Դϴ<D4B4>.
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <a href="http://nova-fusion.com/2012/08/27/lua-for-programmers-part-1/">BlackBulletIV<EFBFBD><EFBFBD> "<22><><EFBFBD>α׷<CEB1><D7B7>Ӹ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>"</a><EFBFBD><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߽<EFBFBD><EFBFBD>ϴ<EFBFBD>. <20>״<EFBFBD><D7B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <a href="http://www.lua.org/pil/contents.html">"<22><><EFBFBD>α׷<CEB1><D7B7><EFBFBD> <20><><EFBFBD><EFBFBD>"</a> å<><C3A5> <20>о<EFBFBD><D0BE><EFBFBD><EFBFBD>ϴ<EFBFBD>.
<EFBFBD>׷<EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>Ƹ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD>.
lua-users.org<72><67> <20>ִ<EFBFBD> <a href="http://lua-users.org/files/wiki_insecure/users/thomasl/luarefv51.pdf">ª<EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD>۷<EFBFBD><DBB7><EFBFBD></a><EFBFBD><EFBFBD>
<EFBFBD>о<EFBFBD><EFBFBD>θ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>𸣰ڽ<F0B8A3B0><DABD>ϴ<EFBFBD>.
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ǥ<><C7A5> <20><><EFBFBD>̺귯<CCBA><EAB7AF><EFBFBD><EFBFBD> <20><><EFBFBD>ؼ<EFBFBD><D8BC><EFBFBD> <20>ٷ<EFBFBD><D9B7><EFBFBD> <20>ʾҽ<CABE><D2BD>ϴ<EFBFBD>.
* <a href="http://lua-users.org/wiki/StringLibraryTutorial">string <20><><EFBFBD>̺귯<CCBA><EAB7AF></a>
* <a href="http://lua-users.org/wiki/TableLibraryTutorial">table <20><><EFBFBD>̺귯<CCBA><EAB7AF></a>
* <a href="http://lua-users.org/wiki/MathLibraryTutorial">math <20><><EFBFBD>̺귯<CCBA><EAB7AF></a>
* <a href="http://lua-users.org/wiki/IoLibraryTutorial">io <20><><EFBFBD>̺귯<CCBA><EAB7AF></a>
* <a href="http://lua-users.org/wiki/OsLibraryTutorial">os <20><><EFBFBD>̺귯<CCBA><EAB7AF></a>
<EFBFBD>׳<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD> <20><>ü<EFBFBD><C3BC> <20><>ȿ<EFBFBD><C8BF> <20><><EFBFBD><EFBFBD> <20><><EFBFBD>α׷<CEB1><D7B7>Դϴ<D4B4>. <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
learn.lua<75><61> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> "lua learn.lua"<22><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!
<EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> tylerneylon.com<6F><6D> ó<><C3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><20><><EFBFBD≯<EFBFBD>,
<a href="https://gist.github.com/tylerneylon/5853042">Github<EFBFBD><EFBFBD> Gist</a><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Ȯ<><C8AE><EFBFBD><EFBFBD> <20><> <20>ֽ<EFBFBD><D6BD>ϴ<EFBFBD>.
<EFBFBD><EFBFBD><EFBFBD>Ʒ<EFBFBD> <20><><EFBFBD>ſ<EFBFBD> <20>ð<EFBFBD><C3B0><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!