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);

  


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM