Moderators IIYAMA Posted May 17, 2013 Moderators Posted May 17, 2013 Is there any special differences between those two local functions: local myFunction = function () end local function myFunction () end Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
RaceXtreme Posted May 17, 2013 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. RaceXtreme
Moderators IIYAMA Posted May 18, 2013 Author Moderators Posted May 18, 2013 are they 100% the same? with the same performance? Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
DiSaMe Posted May 18, 2013 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.) -
Moderators IIYAMA Posted May 18, 2013 Author Moderators 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. Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
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