Only one method runs at a time (in the simplest case, which is the default and the most common in most languages), and since local variables only exists while a function is running, i.e. get created when the function is called and destroyed when it returns, there is no such local during the execution of red
.
Now, when you add concurrency, it's possible that red
and blue
run at the same time (but normally, you'd never know nor should you care). But var
is still a local variable of blue
, so even if there was some heck to get its value, doing so would be utterly insane and a crime against good practice. Sharing state between threads via globals is enough of a pitfall, no need to throw the locals in the mix as well.
What are you really trying to do? You propably want an instance variable (self.var = ...
) or return
something from blue
.