external module - table inside a function implementation - calling and cleanup REDUX

I am coming to terms with the whole external module thingy.
and I was just wondering am I totally bastardizing the last function ?
I created a table in the last function helloWorld3 inside of the external module(example.lua)
that I want to pass back to the main,lua.

I did it, but the way I did is kindof funky looking.
See the below assignment —> local “abc”

My question is, Should I be using a different syntax for this “call”
and how would the proper cleanup/garbage collection ? abc = nil

OK, here is the main.lua code
[lua]-- main.lua
local example = require( “example” )

local hel = example.helloWorld
hel() – output
print(type(hel))

local lo = example.helloWorld2
lo() – output
print(type(lo))

local abc = example.helloWorld3
print(abc()[1] )[/lua]
OK, here is the example.lua code
[lua]-- example.lua
module(…, package.seeall)

function helloWorld()
print( “Hello” )
end

function helloWorld2()
print( “World” )
end
function helloWorld3()
local troy = {}
troy[1] = 10
–print (troy[1])
return troy
end[/lua]
[import]uid: 11094 topic_id: 18875 reply_id: 318875[/import]

Posting code within [lua] and [/lua] tags would make it easier to read! [import]uid: 64174 topic_id: 18875 reply_id: 72726[/import]

You mean “< lua >” and “”

c [import]uid: 24 topic_id: 18875 reply_id: 72753[/import]

Yeah <lua> and </lua> tags!
My Bad! :slight_smile: [import]uid: 64174 topic_id: 18875 reply_id: 72756[/import]

code updated [import]uid: 11094 topic_id: 18875 reply_id: 72785[/import]

Your assigment and call are good… Regarding your external modules, i would suggest you take a look at this
http://blog.anscamobile.com/2011/09/a-better-approach-to-external-modules/

So your example.lua will be something like
[lua]local function helloWorld()
print( “Hello” )
end

local function helloWorld2()
print( “World” )
end

return {helloWorld,helloWorld2}[/lua]
and in your main.lua
[lua]local example = require( “example” )
local hel = example[1]
local lo = example[2][/lua]

Less globals this way… [import]uid: 64174 topic_id: 18875 reply_id: 72798[/import]

thanks !! sorry but no matter how much I read the “programming in lua” manual
I cant really understand it. but when I see the code, and I enter it, It seems to stick
in my head. thanks.

i do wanna understand the specifics and make “lean” code with little to no overhead.

thanks satheesh
[import]uid: 11094 topic_id: 18875 reply_id: 72854[/import]