# DAY 6
0
Blockchain

## 型別介紹

### 整數(Integer)

``````int8 public num = -127;
int16 public num2 = 32767;
int256 public num3 = -3;
int public num4 = 4; //相當於int256

uint8 public num5 = 255;
uint public num6 = 6; //相當於uint256
``````

### 布林(Boolean)

``````bool public isTrue = true;
bool public isFalse = false;
``````

### 字串(String)

``````string public message = "HelloWorld";
``````

``````string public message = "HelloWorld";
message.length; //error
message; //error
``````

### 位元組(Bytes)

``````bytes public buffer = "HelloWorld";
``````

### 陣列(Arrays)

``````uint[] public arr; //動態陣列
uint public arr2; //長度為5的靜態陣列
uint arr3; //2行2列的二維陣列
arr.push(1); //添加1至arr
``````

``````address public owner = 0xfd9ab01f1B3BcA9Ff27FD4DB6069aE04c5f88664;
``````

### 結構(Struct)

``````struct Profile {
string name;
uint8 age;
}

Profile user = Profile({ name: "John", age: 40 });
``````

### 列舉(Enum)

``````enum Member {
normal,
VIP
}

struct Profile {
string name;
uint8 age;
Member membership
}

Profile user = Profile({
name: "John",
age: 40,
membership: Member.VIP
});
``````

### 映射(Mapping)

``````struct Profile {
string name;
uint8 age;
}

mapping(Profile => uint) public balances; //error
``````

• 整數(Integer)
• 布林(Boolean)
• 字串(String)
• 位元組(Bytes)
• 陣列(Arrays)
{"ft_lang_label":"__label__zh","ft_lang_prob":0.7417514,"math_prob":0.48404658,"size":1556,"snap":"2020-24-2020-29","text_gpt3_token_len":897,"char_repetition_ratio":0.14497423,"word_repetition_ratio":0.10047847,"special_character_ratio":0.3014139,"punctuation_ratio":0.15471698,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.95809555,"pos_list":[0,1,2],"im_url_duplicate_count":[null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-06-06T02:37:49Z\",\"WARC-Record-ID\":\"<urn:uuid:6feb10d8-edfb-40fa-84ab-d71e7bf10993>\",\"Content-Length\":\"58295\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:dfee17de-fe5d-4d3e-a748-4757e9e55365>\",\"WARC-Concurrent-To\":\"<urn:uuid:86f1080f-d06f-42a3-afcb-7355fb3e6c71>\",\"WARC-IP-Address\":\"52.199.233.37\",\"WARC-Target-URI\":\"https://ithelp.ithome.com.tw/articles/10218914\",\"WARC-Payload-Digest\":\"sha1:MUMIBVEYKJX3H4YDDM4G6JKYLSVDHXJC\",\"WARC-Block-Digest\":\"sha1:WCDCJG7JX5NZW727LFZ5QRMPYUPIMBSN\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-24/CC-MAIN-2020-24_segments_1590348509264.96_warc_CC-MAIN-20200606000537-20200606030537-00327.warc.gz\"}"}