From: matz@... (Yukihiro Matsumoto) Date: 2000-10-13T08:12:31+09:00 Subject: [ruby-talk:5485] Re: Some newbye question Hi, In message "[ruby-talk:5483] Re: Some newbye question" on 00/10/13, Davide Marchignoli writes: |> def example |> a = 99 |> return proc { |n| n + a } |> end |> |> x = example |> x.call(2) # => 101 |My question was about variable n, the block does not necessarly introduces |a fresh variable, instead it (possibly) binds it to an already existing |variable. IMHO this treatement of variables occurring as argument of |blocks is unrelated to the creation of closures. It is necessary. For example fact = proc{|n| n == 0 ? 1 : fact.call(n-1)*n } p fact.call(4) would return 0 if the block does not introduce a new scope. But I still want to remove the stumble stone like: ary.each do |x| if cond?(x) break end end found = x # error; x is not defined here. in the future, probably Ruby 2.0/3.0 or so. matz.