On Friday, 7 March 2014 at 00:10:20 UTC, bearophile wrote:
captain_fid:

struct S
{
 int a;
 string b;
}

class A
{
  S[] items;
  abstract void doit();
}

class B: A
{
this() {items = [ {10, "first"}, {20, "second"}];} // line 21
  override void doit() { }
}

(21): Error: found '}' when expecting ';' following statement
(21): Error: found ',' instead of statement

For reasons I don't know that {} syntax doesn't always work in D. So try:

this() {
    this.items = [S(10, "first"), S(20, "second")];
}

Bye,
bearophile

Going to have to buy the whole bar a round. Thanks bearophile for the quick fix!

Reply via email to