-
Context: Say I have a function that uses a couple of variables that are tables, the content of which is created during the execution of the function. How should I declare these variables and initialize them? Is the approach below aligned with how you expect folks to address initializing tables? How is there another approach that is idiomatic?
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The most idiomatic is something like you did: a table constructor that holds all the relevant fields. Pallene doesn't like building tables incrementally. In Lua, one thing that is sometimes done is start with an empty table and then set each field using assignment statements. However, in Pallene that kind of thing isn't easy to do, because Pallene doesn't allow assignment statements to change the type of a table. |
Beta Was this translation helpful? Give feedback.
The most idiomatic is something like you did: a table constructor that holds all the relevant fields.
Pallene doesn't like building tables incrementally. In Lua, one thing that is sometimes done is start with an empty table and then set each field using assignment statements. However, in Pallene that kind of thing isn't easy to do, because Pallene doesn't allow assignment statements to change the type of a table.