以太坊solidity基礎4


はいれつ
pragma solidity ^0.4.5;

contract pcl {
    uint[3] a=[1,2,3];  //       3 uint       
    uint[] b=new uint[](0);     //       0 uint       
    uint[2][3] c=[[1,2],[1,2],[1,2]];   //       3       
    uint[2][] d=new uint[2][](0);       //       0       ,    push       

    function change_a(uint aa) {
        a[0]=aa;
    }

    function change_b_length(uint b_l) {
        b.length=b_l;
    }

    function change_b_push(uint b_push) {
        b.push(b_push);
    }
    
    function get_a() constant returns (uint[3]){
        return a;
    }
    
    function get_blength() constant returns(uint){
        return b.length;
    }

    function get_b() constant returns (uint[]){
        return b;
    }
}

こうぞうたい
pragma solidity ^0.4.5;

contract pcl {
    struct dongwu{      //       。                    。(     ??)
        string name;
        uint age;
    }

    dongwu xiaomao=dongwu('  ',2);

    function get() constant returns (string){
        return xiaomao.name;
    }
}

マッピング
pragma solidity ^0.4.5;

contract pcl {
    mapping (address=>uint) balance;        //      Python   dict

    function add(address add,uint usdt) {
        balance[add]+=usdt;
    }

    function get(address add) constant returns (uint){
        return balance[add];
    }
}