lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]



Thank you very much to all of you for your precise answers and nice examples, it is perfectly clear for me now.


De: "Tim Hill" <drtimhill@gmail.com>
À: "Lua mailing list" <lua-l@lists.lua.org>
Envoyé: Mercredi 13 Août 2014 00:47:20
Objet: Re: Accented variable names


On Aug 12, 2014, at 3:34 PM, astient@laposte.net wrote:
Any string (and any other value as well except nil) can be used as a table key so, as you note, table[“caché”] is perfectly valid. As a convenience, Lua provides syntactic sugar when the table key is a valid identifier, allowing you to use table.foo as shorthand for table[“foo”]. However, caché is NOT a valid identifier, and so of course you cannot use the shorthand syntax for table indexing in this case. This is also true for many other strings, for example table[“12”] is valid (and quite different from table[12] of course), but table.12 is not.

—Tim