title: Initializing Instance Variable as an Array - Ruby
body: <p>I'm trying to initialize and instance variable as an array as follows:</p>
  
  <pre><code>  class Arch &lt; ActiveRecord::Base  
    attr_accessor :name1
  
      def initialize
        @name1 = []
      end
  
      def add_name1(t)
        @name1 &lt;&lt; t
      end
  
    end
  </code></pre>
  
  <p>When I try Arch.new in a console session I get (Object doesn't support #inspect). What's up? How do I make an instance array variable? I tried to follow <a href="http://blog.dalethatcher.com/2008/03/rails-dont-override-initialize-on.html" rel="nofollow">this</a> like so:</p>
  
  <pre><code>class Arch &lt; ActiveRecord::Base
  attr_accessor :name1
  
    def after_initialize
      @name1 = []
    end
  
    def add_name1(t)
      @name1 &lt;&lt; t
    end
  
  end
  </code></pre>
  
  <p>and my @name1 was still a NilClass. :/</p>