This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
MR_nesquick's profile picture

[Question] function

Started by MR_nesquick, 17 January 2014 - 01:17 PM
MR_nesquick #1
Posted 17 January 2014 - 02:17 PM
Hello :D/>

i'm just wondering… what's the difference between
function a(param1, param2)
and
a = function(param1,param2)
???
robhol #2
Posted 17 January 2014 - 02:21 PM
Nothing.
OReezy #3
Posted 17 January 2014 - 02:26 PM
function a() is syntactic sugar for a = function(). The only time it actually matters which method you use is when you put functions inside a table

local table = { a = function(var) print(var) end,}

table.a("Hello World") --> Hello World
MR_nesquick #4
Posted 17 January 2014 - 02:40 PM
.
Edited on 17 January 2014 - 01:40 PM
Bomb Bloke #5
Posted 17 January 2014 - 08:09 PM
This post expands further on the subject.
theoriginalbit #6
Posted 17 January 2014 - 08:17 PM
To expand on the link to my explanation that Bomb Bloke posted, the main section you should read is the spoilers.
Now the spoilers directly deal with localised functions, due to the fact that it is where the way you define begins to differ, but it will definitely help you understand better :)/>