2013-08-27 23 views

回答

2

有沒有問題,做這樣的事情:

class Field { 
    String name; 
    Field(Field other) { 
    // init current with other 
    } 
    Field copy() => new Field(this); 
} 
1

你似乎缺少一個大括號,你沒有一個構造函數。除此之外,沒有理由不這樣做:

class Field {  
    Field ref; 

    Field(this.ref); 

    Field copy() { 
    return new Field(this); 
    } 
} 

Field a = new Field(null); 
Field b = a.copy(); 
print(identical(a, b.ref)); // true 
相關問題