Jump to content




Api Advanced


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

#21 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 13 September 2013 - 11:11 PM

View PostSymmetryc, on 13 September 2013 - 08:15 PM, said:

I guess it's just a matter of preference; I like that way for defining functions within tables, but I know that the other method has its benefits as well :).
Indeed it is a matter of preference and as for defining functions within tables it is the only way to do it, it'll error if you try it the other way

Invalid
local t = {
  function x()
  end
}

Valid
local t = {
  x = function()
  end
}


#22 Symmetryc

  • Members
  • 434 posts

Posted 14 September 2013 - 08:56 AM

View Posttheoriginalbit, on 13 September 2013 - 11:11 PM, said:

View PostSymmetryc, on 13 September 2013 - 08:15 PM, said:

I guess it's just a matter of preference; I like that way for defining functions within tables, but I know that the other method has its benefits as well :).
Indeed it is a matter of preference and as for defining functions within tables it is the only way to do it, it'll error if you try it the other way

Invalid
local t = {
  function x()
  end
}

Valid
local t = {
  x = function()
  end
}
Yeah, that's what I meant :P; I like defining my functions within the table, but some people define their functions outside of the tables like this:
local t = {}
t.something = function()
  print("hi")
end
So it really depends on what way you like doing things.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users