Hi,

I've just encountered somehow strange (for me) behavior of nested
methods in ruby:

class A
  def a
    def b
      print "bbb"
    end
  end

  def c
    b
  end
end

irb(main):013:0> A.new.c
bbb=> nil

class A
  def b
    print "BBB"
  end
end
irb(main):019:0> A.new.c
BBB=> nil

my first thought was that method/function 'b' would be local to
method 'a' in class A (like it would be in Pascal). But this is of
course not
the case, as the above example shows.

Is suppose that method 'a' (re)defines  method 'b' every time it is
called, therefore  using nested methods doesn't seem to be a
good idea in ruby (better readability but much worse performance, esp.
when 'b' isn't a oneliner)


any comments?