Closed raould closed 9 years ago
Here you have a similar issue to what you reported in #37. Even though you declare the interface Player
, when you write local Player = { drawer = nil }
, the type of the local Player
is {}
. That is the reason why you get a type error when you try to access the field drawer
inside new
.
Thanks! I'll try to experiment & learn & understand how to do it.
(I think if you have the luxury of free time, it would be super great to have more worked up example code (well, put them in the tests cases, ideally probably :-) that shows these kinds of code designs, and how they are correctly done with TL. So having more than one class, having classes contain member fields that are themselves other class types, etc.)
https://github.com/raould/typedlua/tree/master/QUESTIONS/5
So the difference is the initial value for the table? It is weird to me to have to do it this way because I want the drawer value to only be set; via the new() call. The way this appears to work to me now, I have to have some bogus non-nil default value for everything, including other object types or whatever, which seems a tad sad (duplication of code).
Is the right thing to do to have local Player = { drawer:{} } ?
thanks!