Mature Posted February 7, 2020 Share Posted February 7, 2020 (edited) Hello community, I have the following question, what is the difference between a local function and a function? Example: local function () For this function () When should I use a local function and when should I use a common function? Edited February 7, 2020 by Hazardinho Link to comment
Moderators IIYAMA Posted February 7, 2020 Moderators Share Posted February 7, 2020 (edited) 47 minutes ago, Hazardinho said: When should I use a local function and when should I use a common function? A local function is just the function value saved inside of a local variable. Like this (a local available before the function is defined): local test function test () end or this (a global, as well as a local after the local keyword): function test () end local test = test or this: (a local variable, available after the function) local test = function () end or this: (a local variable, available in and after the function) local function test() end So when do you need to use it? The same way as just a regular local variable. Variables that are accessed a lot of time. (onClientRender) Variables that are only available within it's scope. Variables that are temporary required. etc. Edited February 7, 2020 by IIYAMA 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