View Single Post
10-07-15, 03:03 PM   #6
Nikita S. Doroshenko
A Cyclonian
 
Nikita S. Doroshenko's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2015
Posts: 45
Originally Posted by jeruku View Post
As Phanx pointed out that is not necessary. If you are concerned about variable scoping you can use a do-end block.

Lua Code:
  1. local scopeA = 4
  2. do
  3.    local scopeB = 5
  4.    scopeA = scopeA + scopeB
  5. end
  6. print(scopeA, scopeB)
That will output "9 nil" since scopeB ended with the block.
Thank you for pointing me guys, I just like to separate my code in to blocks (I like this way of code organization), so in my AddOn, all my code packed in to different functions.
I never programmed before, so I don't know any languages at all, only a bit of lua, and I'm learing the best practice. And for sure, i want to write my code well and in correct way.
But even when i see Blizzard's code (who could think, it's one of the top game company in a world, and most known company), and their interface code looks messy in some files, and style of code different, and looks like that they don't even have a code standard, I find this very strange. Same thing about graphic UI standard, there are lot's of little bugs or mess.

Last edited by Nikita S. Doroshenko : 10-07-15 at 03:07 PM.
  Reply With Quote