Ruby parse order

Posted by bresc on Stack Overflow See other posts from Stack Overflow or by bresc
Published on 2010-05-07T18:29:15Z Indexed on 2010/05/07 18:58 UTC
Read the original article Hit count: 137

Filed under:
|
|

Hi,

given this code:

class Foo
  def bar
    return Bar.new
  end
end

class Bar
  ...
end

I get this error:

NameError: uninitialized constant Bar

This obviously works if I put Bar before Foo but that is not a real solution though.

Any ideas on how to solve this without considering the order?

Many thanks.

© Stack Overflow or respective owner

Related posts about ruby

Related posts about error