Skip to content

Instantly share code, notes, and snippets.

@code-brewer
Created September 29, 2018 02:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save code-brewer/872afec9973027cd0664b3b9857f1759 to your computer and use it in GitHub Desktop.
Save code-brewer/872afec9973027cd0664b3b9857f1759 to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.4.25+commit.59dbf8f1.js&optimize=false&gist=
pragma solidity 0.4.25;
/*数组类型Demo*/
contract DemoTypes303 {
/*String数组例子*/
string[] strArr;
function add(string str) public {
strArr.push(str);
}
function getStrAt(uint n) public constant returns (string s){
string storage tmp = strArr[n];
return tmp;
}
function updateStrAt(uint n, string str) public {
strArr[n] = str;
}
function deleteStrAt(uint index) public {
uint len = strArr.length;
if (index >= len) return;
for (uint i = index; i<len-1; i++) {
strArr[i] = strArr[i+1];
}
delete strArr[len-1];
strArr.length--;
}
}
pragma solidity ^0.4.25;
contract EventFilterTest {
constructor() public {
b = 0x12345678901234567890123456789012;
}
event Event(uint indexed a, bytes32 b) ;
event Event2(uint indexed a, bytes32 b) ;
function foo(uint a) public {
b = bytes32(1);
emit Event(a, b);
emit Event2(a, b);
}
bytes32 b;
}
pragma solidity ^0.4.25;
contract SimpleStorage {
uint public data;
// event SetX(address indexed _from, uint value);
event Set(string label, uint value);
function set(uint x) public {
data = x;
// emit SetX(msg.sender, x);
// emit Set("#####", x);
}
}
pragma solidity 0.4.25;
contract C {
uint[] data1;
uint[] data2;
function appendOne() public {
append(data1);
}
function appendTwo() public {
append(data2);
}
function append(uint[] storage d) internal {
d.push(1);
}
function getData1() view public returns(uint[]){
return data1;
}
function getData2() view public returns(uint[]){
return data2;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment