lua-users home
lua-l archive

table constructor and loadstring()?

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hello,
I'm trying to load a table from a string, using loadstring(). This works alright, but I'm somewhat unsure about the proper syntax for the table...
To load the table, I do the following:
local aContent = aFile:read( "*all" )
local aChunk, aStatus = loadstring( "return " .. aContent )
local aTable = aChunk()
But if I use the following construct:
{
	"669" = "audio/x-mod"
}
... loadstring() fails with the following exception:
[string \"return {...\"]:2: `}' expected (to close `{' at line 1) near `='
If I use the more formal bracket notation:
{
	[ "669" ] = "audio/x-mod"
}
... everything works fine.
What gives?
For the record I'm using lua-5.1-work5.
Thanks!
Cheers
--
PA, Onnay Equitursay
http://alt.textdrive.com/

AltStyle によって変換されたページ (->オリジナル) /