2017-02-28 9 views
0

の配列を使用して、私は次のようなデータ構造との契約を持っている:はソリディティ - 充填および配列

struct Answer 
{ 
    bytes32 name; // short name (up to 32 bytes) 
    uint voteCount; // number of accumulated votes 
} 

struct Question 
{ 
    bytes32 name; // short name (up to 32 bytes); 
    Answer[] answers; 
} 

Question[] public questions; 

にはどうすれば配列を埋めることができますか?

次の行では機能しません。

function addQuestion(bytes32 _name, bytes32[] _answers) onlyOwner { // perhabs it should be possible that others as the owner can add 
    Answer[] memory answersLocal = new Answer[](_answers.length); 

    //Question memory question = Question(_name); 
    for (uint i = 0; i < _answers.length; i++) { 
    answersLocal[i] = Answer({ 
     name: _answers[i], 
     voteCount: 0 
     }); 
    } 

    questions.push(Question({ 
     name: _name, 
     answers: answersLocal 
     })); 

    } 

は、私がここでエラーが出ます:

Copying of type struct Roadshow.Answer memory[] memory to storage not yet supported.

答えて

0

あなたはこのようなweb3か何かブリッジを経由して契約にアクセスしようとしている場合。

まだブリッジは配列の配列をサポートしていませんが、強固なサポート!

エラーが固い場合は、別の種類のエラーが表示されます。

これが役に立ちます。