Moderators IIYAMA Posted May 17, 2013 Moderators Share Posted May 17, 2013 Is there any special differences between those two local functions: local myFunction = function () end local function myFunction () end Link to comment
RaceXtreme Posted May 17, 2013 Share Posted May 17, 2013 No, its the same thing When you type function MyFunction (), Lua just declare a variable called MyFunction thats refer to a function. The local term will just make this function valid for a pice of code. Link to comment
Moderators IIYAMA Posted May 18, 2013 Author Moderators Share Posted May 18, 2013 are they 100% the same? with the same performance? Link to comment
DiSaMe Posted May 18, 2013 Share Posted May 18, 2013 http://www.lua.org/manual/5.2/manual.html#3.4.10 The statement local function f () body end translates to local f; f = function () body end not to local f = function () body end (This only makes a difference when the body of the function contains references to f.) Link to comment
Moderators IIYAMA Posted May 18, 2013 Author Moderators Share Posted May 18, 2013 ok, I only don't understand what they mean with this: (This only makes a difference when the body of the function contains references to f.) -What is "f"? Is that the function that contains the function? Can you give me two samples when I better can use: local function f () body end --and local f = function () body end Because in my opinion the website isn't very clear. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now