Now you, could of course, print v1 outside of the class and
you will get the "outside", because that's the same scope.
And if you print local variables at this point, you'll get v1.
And you'll also get object, which is this variable,
which was defined a few lines ago.
So that's how variable is work.
Now constants are basically any reference that begins with uppercase,
including classes, modules or any other constants.
And the constant scope rules are different than variable scope rules.
The inner scope constants can see constants defined in the outer scope and
they can also override our outer constants.
Although outside of that inner scope, the value remains unchanged for constants.
So let's see an example.
Let's say, we have a value of PI,
which starts with an uppercase, wherever is all that matters.
And you define that it is 3.14 and then you wanna use that all
the way inside the class Test2, inside the method what_is_pi.
That's fine, because it's a constant.
You wouldn't be able to do it with a variable.
So in this case, you got an exception thrown, but
you could do it with a constant without a problem.
Now if you had a constant called MyConstant and
then you override the value Outer Constant here.
And MyConstant = Inner Constant prints Inner Constant, but
outside that constant is still known as Outer Constant.
So point is you could use it, but once you define it as a new value,
that value becomes the new value of a constant.
But when you go back out to the outer scope, you're back to the original value.
Now the change in the value of a constant is kinda weird,
because the whole point of it is that it should be a constant.
So for example, the value of PI will probably be the same value and
you probably don't wanna be changing it, but
I'm just pointing out the way it actually works.
So if for whatever reason you see some behavior and you're not sure why it's
happening, the first thing you should check is, are you name your variables
correctly of the lower case while your naming them with upper case.
In which case, it's a constant, which means it has this behavior.
Now we move on to scope of blocks.
Blocks are not like methods.
So the variables in the blocks actually inherit the outer scope and
this is beyond this lecture, but a block actually is a closure.
If you remember, it was the context in which it was defined and
uses that context whenever it is called,
but just to show you an example specifically for a scope portion.
Let's say, you have a class called BankAccount,
which maybe has an id and an amount that you are putting into the bank.
That you're instantiating your bank account with and
then you have an array of three different BankAccounts.
Maybe in the amount of 200, 100 and -100 and
then you wanna add up the amount in all those three accounts.