On Sun, Feb 9, 2014 at 12:10 AM, Vladimir Klenov <lists / ruby-forum.com> wrote:
> ahh. i need to sorry for a first, i was too rude but you dont ban me,
> heh,
> and i appreciate it. sorry again. my point was:
> def blabla
>    common_name = value
>    ... some code
>    sub block
>       common_name = again # unintentially break variable value
>    end
>
>
> end
>
> so nobody including IDE can know i was rewritten outer variable.

First of all: no IDE in the world can know your intentions.  Consider

def max(enum)
  m = 0
  enum.each {|i| m = i if i > m}
  m
end

In this case it's intentional that m is overwritten inside the block.
So there will be never an automated mechanism which will generally
warn you.

> i just want to way if you declare var inside block nothing dangerous
> should happen. ruby borrows many from perl and in perl its ok. and yes,
> i prefer to program javascript

You can do this:

$ ruby -e 'x=666;p x;2.times {|i,x=8| p [i,x];x=i}; p x'
666
[0, 8]
[1, 8]
666
$ ruby -e 'x=666;p x;2.times {|i;x| p [i,x];x=i;p x}; p x'
666
[0, nil]
0
[1, nil]
1
666

Cheers

robert

-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/