title: Ruby - NameError: uninitialized constant when accessing name of my derived class
body: <p>I have class B derived from class A, like:</p>
  
  <pre><code>class A
  ..
  end
  
  class B &lt; A
  ...
  end
  </code></pre>
  
  <p>In another file I defined a variable M</p>
  
  <pre><code>M = B
  </code></pre>
  
  <p>Then I got the error </p>
  
  <pre><code>"NameError: uninitialized constant B".
  </code></pre>
  
  <p>I just found that if I write</p>
  
  <pre><code>M=A
  M=B
  </code></pre>
  
  <p>Then it's OK. It seems I have to initialize A in some way.</p>