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