码迷,mamicode.com
首页 > 其他好文 > 详细

lua函数返回多个值

时间:2017-08-19 15:46:42      阅读:183      评论:0      收藏:0      [点我收藏+]

标签:print   source   exec   function   return   取字符串   read   pre   对比   

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

  

lua函数返回多个值

标签:print   source   exec   function   return   取字符串   read   pre   对比   

原文地址:http://www.cnblogs.com/ReacherGua/p/7396639.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!