lua函数返回多个值

function CompareString(in_source, in_compare)

	local ret_value;
	local ret_msg;

	if (in_source >  in_compare) then
		value =	1;
		msg = 'source greate then';
	end

	if (in_source <  in_compare) then
		  value =	-1;
		  msg = 'source less then';
	end

	if (in_source ==  in_compare) then
		value =	0;
		msg = 'source equal then';
	end

	return value,msg;
end

source_string = "reacher";
in_string = io.read();

--获取字符串对比函数输入
execute_status, ret_msg = CompareString(source_string, in_string);
print('get execute status:'..execute_status);
print(ret_msg);

  

posted @ 2017-08-19 15:03  瓜子啊  阅读(2563)  评论(0编辑  收藏  举报