Jump to content

technical question


IIYAMA

Recommended Posts

  • Moderators
Posted

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 

  Tutorials  4x 

 

Posted

No, its the same thing :D

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
Posted

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 

  Tutorials  4x 

 

  • Moderators
Posted

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 

  Tutorials  4x 

 

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...