local variables:
local variables are the one whose scope is only till the end of the function/method.
global variables:
global variables are the one whose scope is through the way to the end of the program.
non-local:
technically global and non-local variables are same.
Tips:
global or local variable of any type can't be both at the same time, but they sure can share the same name. it wont cause any trouble, almost all languages, it's legal but still better to avoid. but there is a 'but'. if a global and a local variable shares the same name, the local one will hide/omit the global.
local variables are the one whose scope is only till the end of the function/method.
global variables:
global variables are the one whose scope is through the way to the end of the program.
non-local:
technically global and non-local variables are same.
Tips:
global or local variable of any type can't be both at the same time, but they sure can share the same name. it wont cause any trouble, almost all languages, it's legal but still better to avoid. but there is a 'but'. if a global and a local variable shares the same name, the local one will hide/omit the global.
No comments:
Post a Comment