table constructor and loadstring()?
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: table constructor and loadstring()?
- From: PA <petite.abeille@...>
- Date: 2005年3月10日 18:35:42 +0100
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/