[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Overloading the '=' operator for a table
- From: "RJP Computing" <rjpcomputing@...>
- Date: Tue, 18 Nov 2008 12:38:51 -0500
I searched briefly and didn't find a solution. I am wondering if there is a metatable for the "=" operator on tables. I want to wrapp a class that has a value and other data, but didn't want to have to use the .value syntax.
Example:
parameter = {
Value = 0,
Type = "U8",
Comment = "This is a comment"
}
listOfParameters = {
Parameter1 = parameter,
Parameter2 = parameter
}
-- Setting value without magic.
listOfParameters["Parameter1"].Value = 50
listOfParameters.Parameter2.Value = 10
-- This is what I would like to to look like.
listOfParameters["Parameter1"] = 50 -- This would actually set the value 50 to 'Value'
table.foreach( listOfParameters, print )
listOfParameters.Parameter2 = 10
Any thoughts?
--
Regards,
Ryan