Lua 尝试返回多个值,attempt to compare nil with number
--[[
s,e=string.find("hello Lua users","Lua")
print(s,e)
--]]
function maximum (a)
local mi = l
local m = a[mi]
for i,val in ipairs(a) do
if val > m then
mi = i
m = val
end
end
return m,mi
end
print(maximum({8,10,23,12,5}))
报错:
Exception in thread "main" com.naef.jnlua.LuaRuntimeException: ...\ldt\workspace\test\src\5.1return multiple value.lua:10: attempt to compare nil with number
at com.naef.jnlua.LuaState.lua_pcall(Native Method)
at com.naef.jnlua.LuaState.call(LuaState.java:555)
at org.eclipse.koneki.ldt.support.lua51.internal.interpreter.JNLua51Launcher.run(JNLua51Launcher.java:128)
at org.eclipse.koneki.ldt.support.lua51.internal.interpreter.JNLua51Launcher.main(JNLua51Launcher.java:143)
战场原荡漾
10 years, 3 months ago