title: Creating objects from YAML, already initialized constant
body: <p>Two problems, that probably are related:</p>
  
  <p>I'm retreiving a number of 'persons' from a YAML-file to an array, and now i'm trying to create classes from that array.</p>
  
  <p>These objects are then to placed in a new array.</p>
  
  <p>It actually works out fine, if you dont consider the fact that the object added last replaces <em>all</em> the previously added.</p>
  
  <p>In my case i get five identical copies of object #5, where i rather like to see five different ones.</p>
  
  <p>My guess is that the error results somewhere in my iterator to get all the 'persons' from the YAML.</p>
  
  <p>I'm getting a cuople of warnings, regarding the 're-use' of constants:
  NEWSTR and NEWAL.</p>
  
  <pre><code>getPost = 0
  loopa = 0
  
       while loopa &lt; personsInYAML
          NEWSTR = TEST.fetch(getPost)
          NEWAL = NEWSTR.split(' ')
          getPost+=1
  
          puts "*****************************************"
          nyloop = loopa+1
          puts "PERSON: " + nyloop.to_s + " name: " + NEWAL.fetch(1)
  
          nameToArray = Person.new
          outputArray.insert(loopa, nameToArray)
          loopa+=1
      end
  </code></pre>
  
  <p>Persons-class</p>
  
  <pre><code>class Person
  
      def initialize
          @name
          @age
          @length
          @weight
          @misc
      end
  
  
      def name
          name = NEWAL.fetch(1)
          return name
      end
  
      if NEWAL.include?("age:")
  
          def age
              x = NEWAL.index("age:")+1   
              age =  NEWAL.fetch(x)
              return age
          end
      end
  
      if NEWAL.include?("length:")
          def length
              x = NEWAL.index("length:")+1
              length = NEWAL.fetch(x)
              return length
          end
      end
  
      if NEWAL.include?("weight:")
          def weight
              x = NEWAL.index("weight:")+1
              weight = NEWAL.fetch(x)
              return weight
          end
      end
  
      if NEWAL.include?("misc:")
          def misc
              x = NEWAL.index("misc:")+1
              misc = NEWAL.fetch(x)
              return misc
          end
      end
  end
  </code></pre>