title: How to specify class for instance variable in smalltalk
body: <p>Probably I haven't understood the concepts of smalltalk enough, but here is my problem:</p>
  
  <p>I am creating a class, let's call it <em>Main-class</em>, that has an instance variable <em>bar</em>, that I want to be of a certain class - <em>Other-class</em>, and use this <em>Other-class</em>' methods on that in the <em>Main-class</em> methods kind of like this:</p>
  
  <pre><code>    Object subclass: #Other-class
          instanceVariableNames: 'foo'
          classVariableNames: ''
          poolDictionaries: ''
          category: 'Custom-class'
  
  setFoo: newFoo
  
      foo := newFoo.
  </code></pre>
  
  <p>And the <em>Main-class</em> :</p>
  
  <pre><code>  Object subclass: #Main-class
          instanceVariableNames: 'bar'
          classVariableNames: ''
          poolDictionaries: ''
          category: 'Custom-class'
  
  newBar: val
  
      bar := Bar new. 
      bar setFoo: val.
  </code></pre>
  
  <p>Obviously, I get an error that there is no <em>setFoo</em> method.
  But how do I specify that I want <em>bar</em> to be variable of a specific class and then use that class' methods on it?</p>