2tallhank
|
  |
| Joined: 11 Jun 2010 |
| Total Posts: 2075 |
|
| |
|
swmaniac
|
  |
| Joined: 28 Jun 2008 |
| Total Posts: 15773 |
|
|
| 28 Feb 2012 07:19 PM |
When you define a variable as "local" to the block of code (everything between the function/do/repeat to until/end)
The variable does not exist outside that block of code - this is called the variable's "Scope." |
|
|
| Report Abuse |
|
|
2tallhank
|
  |
| Joined: 11 Jun 2010 |
| Total Posts: 2075 |
|
| |
|
nate890
|
  |
| Joined: 22 Nov 2008 |
| Total Posts: 21686 |
|
|
| 28 Feb 2012 07:23 PM |
"to the block of code (everything between the function/do/repeat to until/end)"
The scope.
"Bro five! Wear this to let everyone know you think they deserve a high five." |
|
|
| Report Abuse |
|
|
nate890
|
  |
| Joined: 22 Nov 2008 |
| Total Posts: 21686 |
|
|
| 28 Feb 2012 07:26 PM |
Making a variable local will only be accessible in the scope it's declared in or any higher scope.
--Scope
while (true) do --Scope2 local a=1 b=2 print(a,b) end print(a,b)
"Bro five! Wear this to let everyone know you think they deserve a high five." |
|
|
| Report Abuse |
|
|
swmaniac
|
  |
| Joined: 28 Jun 2008 |
| Total Posts: 15773 |
|
|
| 28 Feb 2012 07:32 PM |
@nate
I also explained that the block of code in which a local variable is declared is the variable's scope. ._.
A block of code is all code between any given function/if/do/repeat and the end/until that closes it. |
|
|
| Report Abuse |
|
|
nate890
|
  |
| Joined: 22 Nov 2008 |
| Total Posts: 21686 |
|
|
| 28 Feb 2012 07:36 PM |
I'll write a better example, because my last example and statement or both slightly incorrect and vague.
"Bro five! Wear this to let everyone know you think they deserve a high five." |
|
|
| Report Abuse |
|
|