You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
643 B
Solidity

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;
contract ArrayTest {
// 以下标为定义的访问器 1 => 2
uint [] public u = [1, 2, 3];
string s = "abcdefg";
// 获取数组的长度 => string 可以转换成 bytes
function h() public constant returns (uint) {
return bytes(s).length; // 7
}
// 返回下标为1的元素
function f() public view returns (byte) {
// 调用下面的数组
g([uint(1), 2, 3]);
return bytes(s)[1]; // b -> asc 码 0x62
}
// 数组作为参数进行传递
function g(uint[3] _data) public constant {
}
}