基于以太坊的智能合约开发教程 Solidity 函数返回值
pragma solidity ^0.4.0;
contract funreturn{
function returnTest()view returns(uint){
uint a =10;
return a;
}
function returnTest2() returns(uint mul){
mul =100;
}
function returnTest3() returns(uint mul){
uint a =10;
mul =100;
return a;
}
function returnTest4()view returns(uint mul){
uint a = 10;
mul =100;
return 1;
}
// 函数可以有多返回值
function returnTest5(uint a,uint b) view returns(uint add,uint mul){
add = a+b;
mul = a*b;
}
function returnTest6(uint a,uint b) view returns(uint add,uint mul){
return (a+b,a*b);
}
// 交换变量的值
function returnTest7(uint a,uint b) view returns(uint a1,uint a2){
return (b,a);
}
}
|