Tuesday, May 22, 2012

다른 module의 함수를 부르는 예

iTestUtil.lua
 module(..., package.seeall)   
   
 hello = function()  
      print("hello!!!!")  
 end  

main.lua
 local TestUtil = require("iTestUtil")   
 TestUtil.hello() -- 느린 방법   
   
 local hello = TestUtil.hello -- 함수를 cache해서 빠르게 함   
 hello() -- 이제부터는 부를 때마다 빠르게 호출할 수 있음   

No comments:

Post a Comment