Design with appender: good or bad?

Chris wendlec at tcd.ie
Thu Apr 10 02:47:32 PDT 2014


Are there any drawbacks with this design, i.e. using buf.put() 
here
(instead of a less efficient items ~= item;)?

struct MyStruct {
   Appender!(string[]) buf;
   string name;

   this(string name) {
     this.name = name;
     buf = appender!(string[]);
   }

   public addItem(string item) {
     buf.put(item);
   }

   @property string[] items() {
     return buf.data;
   }
}


More information about the Digitalmars-d-learn mailing list