meaning of three dots

Hi, I was wondering if someone could explain to me the meaning of three dots after the local launchArgs variable. I’m doing the tutorial on push notifications and came across to this. thanks

[code]local launchArgs = …

local json = require “json”

if launchArgs and launchArgs.notification then
native.showAlert( “launchArgs”, json.encode( launchArgs.notification ), { “OK” } )
end
[/code] [import]uid: 74667 topic_id: 32953 reply_id: 332953[/import]

Essentially, the dots are a protocol for lua to allow other programs to pass a random number of variables into your lua program (a corona program) when it launches (hence, luanchArgs). See:

http://www.lua.org/pil/5.2.html

http://stackoverflow.com/questions/2945819/interactive-lua-command-line-arguments

The “launchArgs” naming convention (the parmaters are put into that table) appears to be a CoronaSDK convention, (and not generic to lua). But the important thing is, CoronaLabs created this pathway to allow passing variables into your app (for notifications, and perhaps other uses, dot dot dot)…

Best of luck with your endeavor. [import]uid: 79933 topic_id: 32953 reply_id: 130889[/import]

Essentially, the dots are a protocol for lua to allow other programs to pass a random number of variables into your lua program (a corona program) when it launches (hence, luanchArgs). See:

http://www.lua.org/pil/5.2.html

http://stackoverflow.com/questions/2945819/interactive-lua-command-line-arguments

The “launchArgs” naming convention (the parmaters are put into that table) appears to be a CoronaSDK convention, (and not generic to lua). But the important thing is, CoronaLabs created this pathway to allow passing variables into your app (for notifications, and perhaps other uses, dot dot dot)…

Best of luck with your endeavor. [import]uid: 79933 topic_id: 32953 reply_id: 130889[/import]

fantastic explanation @mpappas, many thanks! :slight_smile: [import]uid: 74667 topic_id: 32953 reply_id: 130934[/import]

@potsifera,

FYI, here are some sample uses of … as a function argument

local function ex1( ... ) for i = 1, #arg do print( arg[i] ) end end local function ex2( ... ) print( unpack( arg ) ) end local function ex3( argA, argB, ... ) -- Fixed arguments mixed with variable print( argA, argB, unpack( arg ) ) end



ex1( "Variable", "arguments", "are", "useful" )

Prints:

Variable arguments are useful



ex2( "Variable", "arguments", "are", "useful" )

Prints:

Variable arguments are useful



ex3( "Variable", "arguments", "are", "useful" )

Prints:

Variable arguments are useful

[import]uid: 110228 topic_id: 32953 reply_id: 130955[/import]

fantastic explanation @mpappas, many thanks! :slight_smile: [import]uid: 74667 topic_id: 32953 reply_id: 130934[/import]

@potsifera,

FYI, here are some sample uses of … as a function argument

local function ex1( ... ) for i = 1, #arg do print( arg[i] ) end end local function ex2( ... ) print( unpack( arg ) ) end local function ex3( argA, argB, ... ) -- Fixed arguments mixed with variable print( argA, argB, unpack( arg ) ) end



ex1( "Variable", "arguments", "are", "useful" )

Prints:

Variable arguments are useful



ex2( "Variable", "arguments", "are", "useful" )

Prints:

Variable arguments are useful



ex3( "Variable", "arguments", "are", "useful" )

Prints:

Variable arguments are useful

[import]uid: 110228 topic_id: 32953 reply_id: 130955[/import]

Hi Roaminggamer, 

Thank you for this useful example. FYI there is a little typo in the first function line 2.

[lua]

local function ex1( … )

   for i = 1, #arg do

      print( arg[i] )

   end

end

[/lua]

Thanks.  Yeah I do that with my examples a lot.  Problem is I only run them through the ‘brain simulator’ for the most part instead of checking them on a real simulator first.  I guess I need an upgrade :slight_smile:

Hi Roaminggamer, 

Thank you for this useful example. FYI there is a little typo in the first function line 2.

[lua]

local function ex1( … )

   for i = 1, #arg do

      print( arg[i] )

   end

end

[/lua]

Thanks.  Yeah I do that with my examples a lot.  Problem is I only run them through the ‘brain simulator’ for the most part instead of checking them on a real simulator first.  I guess I need an upgrade :slight_smile: