function setVal(key, value) data.key = value endthis problem is fustrant i wnt to pass the variable to his value and pass that to the table but is not working HEEEELP
pass a variable to his value
Started by FuuuAInfiniteLoop(F.A.I.L), Jan 16 2013 01:52 AM
4 replies to this topic
#1
Posted 16 January 2013 - 01:52 AM
#2
Posted 16 January 2013 - 01:55 AM
What's it doing?
try
try
function setVal(key, value) data[key] = value end
#3
Posted 16 January 2013 - 01:59 AM
thanks why i dont mid on that xDDD
#5
Posted 16 January 2013 - 05:49 AM
That's a little inaccurate. The exact problem is that data.key is precisely equivalent to data["key"], in which key is the literal string "key" and not whatever is contained in the variable with the identifier "key". Thus you need to use data[key], so that you index by the value contained in the variable with the identifier "key" rather than indexing by the literal string value "key".
You can assign new indexes using the format data.key, but the assignment will always be to the literal string value rather than to any variable associated with the identifier.
You can assign new indexes using the format data.key, but the assignment will always be to the literal string value rather than to any variable associated with the identifier.
3 user(s) are reading this topic
0 members, 3 guests, 0 anonymous users











