title: Ruby: How to pass the object name to an array rather than the ID
body: <p>If I create two objects like so:</p>
  
  <pre><code>foo = foo.new
  bar = bar.new
  </code></pre>
  
  <p>and want to store the name of object foo inside an array in bar, how would I do this?</p>
  
  <p>For example if I was passing foo to the following method in bar:</p>
  
  <pre><code>def to_array arg
    fooarray &lt;&lt; arg
  end
  </code></pre>
  
  <p>How can I get it so the method 'to_array' stores the name 'foo' inside the array, rather than the instance ID of the object?</p>
  
  <p>So the array looked like this:</p>
  
  <pre><code>['foo', 'foo2', 'foo3' etc..]
  </code></pre>
  
  <p>rather than</p>
  
  <pre><code>[#&lt;foo:0x00..., #foo2:0x00..., etc..]
  </code></pre>
  
  <p>I really hope this makes sense. I'm new to Ruby so I might not be making myself clear.</p>