Robert Klemme
2/1/2008 10:00:00 AM
2008/2/1, Stefano Crocco <stefano.crocco@alice.it>:
> Alle Friday 01 February 2008, Magicloud Magiclouds ha scritto:
> > Hello,
> > I mean what kind of variable is $var? What is its 'domain'?
> >
> > Thanks.
>
> It's a global variable. This means it's visible from everywhere in your
> program.
Sometimes it's only thread global:
10:56:03 /cygdrive/c/SCMws/RKlemme/OPSC_Gold_bas_dev_R1.2_cug
$ ruby -e '(1..2).map {|i| Thread.new(i) {|a| /\d+/ =~ a.to_s; 2.times
{p [Thread.current, a, $&];}}}.each {|th| th.joi
n}'
[#<Thread:0x1002fd7c run>, 1, "1"]
[#<Thread:0x1002fbd8 run>, 2, "2"]
[#<Thread:0x1002fd7c run>, 1, "1"]
[#<Thread:0x1002fbd8 run>, 2, "2"]
10:59:31 /cygdrive/c/SCMws/RKlemme/OPSC_Gold_bas_dev_R1.2_cug
$
Kind regards
robert
--
use.inject do |as, often| as.you_can - without end