[#863] RDtool-0.5.0 — Toshiro Kuwabara <toshirok@...3.so-net.ne.jp>
Hi,
18 messages
1999/10/23
[#864] Re: RDtool-0.5.0
— matz@... (Yukihiro Matsumoto)
1999/10/26
Hi,
[#865] Re: RDtool-0.5.0
— Toshiro Kuwabara <toshirok@...3.so-net.ne.jp>
1999/10/26
Hi,
[#866] Re: RDtool-0.5.0
— matz@... (Yukihiro Matsumoto)
1999/10/26
Hi,
[#892] Re: RDtool-0.5.0
— Toshiro Kuwabara <toshirok@...3.so-net.ne.jp>
1999/10/31
Hi,
[#894] Re: RDtool-0.5.0
— matz@... (Yukihiro Matsumoto)
1999/11/01
Hi,
[#905] Re: RDtool-0.5.0
— Toshiro Kuwabara <toshirok@...3.so-net.ne.jp>
1999/11/04
Hi,
[#906] Re: RDtool-0.5.0
— matz@... (Yukihiro Matsumoto)
1999/11/04
Hi,
[#907] Re: RDtool-0.5.0
— Kazuhiro HIWADA <hiwada@...>
1999/11/04
Hi,
[#908] Re: RDtool-0.5.0
— kjana@... (YANAGAWA Kazuhisa)
1999/11/05
In message <19991105025532K.hiwada@kuee.kyoto-u.ac.jp>
[#867] call with a Proc — ts <decoux@...>
11 messages
1999/10/28
[#868] Re: call with a Proc
— gotoken@... (GOTO Kentaro)
1999/10/28
Hi,
[#877] local / dynamic variables — ts <decoux@...>
11 messages
1999/10/29
[#878] Re: local / dynamic variables
— gotoken@... (GOTO Kentaro)
1999/10/29
Hi,
[ruby-talk:00885] Re: local / dynamic variables
From:
ts <decoux@...>
Date:
1999-10-30 10:57:27 UTC
List:
ruby-talk #885
>>>>> "G" == GOTO Kentaro <gotoken@math.sci.hokudai.ac.jp> writes:
G> As you see, in the formar case, |i| is shared with the outer scope.
G> A significant use of this feature can be given:
G> a = [4,5,6,3]
G> sum = 0
G> a.each{|i| sum += i}
G> p sum
Well it's not really a use of this feature, because sum is not defined
between | |. Only i is between | | and in this case :
* sum is a local variable
* i is a dynamic variable
My problem is that I've written something like this :
i = 12
# add here some lines
sum = 0
a.each {|i| sum += i}
# add here some lines
p i
and I've lost my old value for i
G> In the book ``Object oriented scripting language Ruby'' (in Japanese),
G> scopes of local variables are illustrated as follows:
Apparently ruby has local_vars and dyna_vars.
G> local2 = 88 # # #<-- scope of local1,local2
local variable
G> # # #
G> loop do # # #
G> local3 = 99 # # # #<-- scope of local3
dynamic variable only if local3 is not a local variable of baz
G> ..... # # # #
Guy Decoux