Jump to content




[Question] function


  • You cannot reply to this topic
5 replies to this topic

#1 MR_nesquick

  • Members
  • 106 posts
  • LocationNorway

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)
???

#2 robhol

  • Members
  • 182 posts

Posted 17 January 2014 - 02:21 PM

Nothing.

#3 OReezy

  • Members
  • 91 posts

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


#4 MR_nesquick

  • Members
  • 106 posts
  • LocationNorway

Posted 17 January 2014 - 02:40 PM

.

Edited by MR_nesquick, 17 January 2014 - 02:40 PM.


#5 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 17 January 2014 - 08:09 PM

This post expands further on the subject.

#6 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

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 :)





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users