I am trying to test out the Lua loadstring function.
This example is taken direction from the Lua documentation:
f = loadstring("i = i + 1")
However, when I try to run it at:
https://www.lua.org/cgi-bin/demo
I get the following error:
input:1: attempt to call a nil value (global 'loadstring')
loadstring
is not available in Lua past version 5.1. The demo you linked is running Lua 5.3. You can prove this by running the program print(_VERSION)
.
In Lua 5.2 an later your code should use load
, here is an example program you can run that loads a chunk from a string:
local f = load("return 2 + 2")
print(f())
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加