user6083685
user6083685

Reputation:

Create array of classes in d

It's my class

module figure;
import block; 
class Figure {
    Block[] body;
    this() {
        this.body ~= new Block();
    }
}

And I got "no identifier for declarator Block[]"

Block.d file

module block;

import std.stdio;

class Block {
  this() {
    writeln("In block.d");
  }
}

Upvotes: 2

Views: 102

Answers (1)

Adam D. Ruppe
Adam D. Ruppe

Reputation: 25605

Oh, the word body is a keyword in D and thus cannot be used as a variable name. Try just about any other name, maybe body_ or just blocks or almost anything else and it will work.

Upvotes: 5

Related Questions