Local variable: Difference between revisions

Content deleted Content added
m Reverted 1 edit by 111.93.109.98 identified as test/vandalism using STiki
11 changes: ce; fix cite error "paragraph=" as "at="
Line 41:
This happens since the global variable $a is modified to a new ''temporary'' (local) meaning inside f(), but the global value is restored upon leaving the scope of f().
 
Using <code>'my'</code> in this case instead of <code>'local'</code> would have printed 1 three times since in that case the <code>$a</code> variable would limited to the static scope of the function f() and not seen by g().<br /> Randal L. Schwartz and Tom Phoenix argue that the operator <code>'local'</code> should have had a different name like <code>'save'</code>.<ref>{{cite book|author=Randal L. Schwartz and Tom Phoenix|title=Learning Perl 3rd edition|paragraphat=paragraph 4.7|publisher=O'REILLY |date=2001-07-01 |ISBN=0-596-00132-0}}</ref>
 
==Local variables in Ruby==