Sorry if this has been rehashed before--I searched the archive and 
didn't find anything that seemed identical to the question I've got.

Which is: if I define a method inside a method, currently the inner 
method has no access to the outer method's local variables.  Is this a 
conscious design decision, or a bug?

  def test_outer( a, b )
     def test_inner( a )
        puts "#{a} and #{b}"
     end

     test_inner( a+b )
  end

  test_outer( 1, 2 )

I would expect "3 and 2" to be the output, but I get an "undefined local 
variable or method `b'" error from test_inner.

Can anyone shed some light on this behavior for me, either in favor of 
it, or at the very least explaining it?  (Yes, I know I could use a 
block, instead of a nested method... but I would like to know why the 
nested method approach fails.)

Thanks,

Jamis

-- 
Jamis Buck
jgb3 / email.byu.edu

ruby -h | ruby -e 'a=[];readlines.join.scan(/-(.)\[e|Kk(\S*)|le.l(..)e|#!(\S*)/) {|r| a << r.compact.first };puts "\n>#{a.join(%q/ /)}<\n\n"'