summaryrefslogtreecommitdiff
path: root/sample
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-04-07 08:34:10 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-04-07 08:34:10 +0000
commitba06b1a81f81e089849c7c877eba7b1d3618b126 (patch)
tree57e77c2ade50f201b4aafdc071cf86fb95eb7016 /sample
parentf8fc9136223c83c2791566d3efa52843f89aa127 (diff)
dynamic (nested) local variables
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@151 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'sample')
-rw-r--r--sample/test.rb11
1 files changed, 6 insertions, 5 deletions
diff --git a/sample/test.rb b/sample/test.rb
index 98c913667a..29670987fa 100644
--- a/sample/test.rb
+++ b/sample/test.rb
@@ -638,14 +638,14 @@ ok($proc.call(2) == 4)
ok($proc.call(3) == 6)
proc{
- iii=5 # dynamic local variable
+ iii=5 # nested local variable
$proc = proc{|i|
iii = i
}
$proc2 = proc {
- $x = iii # dynamic variables shared by procs
+ $x = iii # nested variables shared by procs
}
- # scope of dynamic variables
+ # scope of nested variables
ok(defined?(iii))
}.call
ok(!defined?(iii)) # out of scope
@@ -653,6 +653,7 @@ ok(!defined?(iii)) # out of scope
$x=0
$proc.call(5)
$proc2.call
+p $x
ok($x == 5)
if defined? Process.kill
@@ -715,8 +716,8 @@ def test_ev
end
$x = test_ev
-ok(eval("local1", $x) == "local1") # static local var
-ok(eval("local2", $x) == "local2") # dynamic local var
+ok(eval("local1", $x) == "local1") # normal local var
+ok(eval("local2", $x) == "local2") # nested local var
$bad = true
begin
p eval("local1")