title: Adding StructFields to an existing schema
body: <p>I created a class "Attribute". Each class object has a name, a datatype and a boolean value (nullable or not). All objects are saved to a ListBuffer. </p>
  
  <p>I try to create a schema from the list and pass each value to the StructField(). Initiating works but unfortunately no further items are getting added to the schema.</p>
  
  <pre><code>def create_schema_from_attr_list(attr_list: ListBuffer[Attribute]): StructType = {
    // Get first list item and initiate schema
    var schema = StructType(StructField(attr_list(0).name, attr_list(0).data_type, attr_list(0).nullable) :: Nil)
  
    // Add remaining items
    for (i &lt;- 1 until attr_list.length) {
      schema.add(attr_list(i).name, attr_list(i).data_type, attr_list(i).nullable)
      println("Test " + attr_list(i).name.toString())
    }        
    return schema
  }
  </code></pre>